Wpf を SingleFileで発行
WPFを発行した時に、1ファイルにしたい。
環境/プロジェクト作成
- Uno-Platform App(Unoでやった意味は特にない)
- VisualStudio Pro 2019 (16.8.2)
- Windows 10
ビルド
対象は、UnoWpf.Skia.Wpf.Host
通常起動
発行
<?xml version="1.0" encoding="utf-8"?> <!-- https://go.microsoft.com/fwlink/?LinkID=208121. --> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration>Release</Configuration> <Platform>Any CPU</Platform> <PublishDir>bin\publish\</PublishDir> <PublishProtocol>FileSystem</PublishProtocol> </PropertyGroup> </Project>
設定変更1:
- 配置モード:→自己完結
- 単一ファイル作成:→ON
<?xml version="1.0" encoding="utf-8"?> <!-- https://go.microsoft.com/fwlink/?LinkID=208121. --> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration>Release</Configuration> <Platform>Any CPU</Platform> <PublishDir>bin\publish\</PublishDir> <PublishProtocol>FileSystem</PublishProtocol> <TargetFramework>netcoreapp3.1</TargetFramework> <RuntimeIdentifier>win-x86</RuntimeIdentifier> <SelfContained>true</SelfContained> <PublishSingleFile>True</PublishSingleFile> <PublishReadyToRun>False</PublishReadyToRun> <PublishTrimmed>False</PublishTrimmed> </PropertyGroup> </Project>
減った。
設定変更2:
- NetCore3.1 → .Net5
増えた。
設定変更3:
- プロジェクトファイルに手書きで、IncludeNativeLibrariesForSelfExtract を追記
<PropertyGroup> <OutputType Condition="'$(Configuration)'=='Release'">WinExe</OutputType> <OutputType Condition="'$(Configuration)'=='Debug'">Exe</OutputType> <TargetFramework>net5.0-windows</TargetFramework> <UseWPF>true</UseWPF> <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> </PropertyGroup>
pdb除けば1ファイルに近づいた。
(Unoにしなければ、1ファイルにできたかも…)
おわり