WinUI3 アプリケーションのターゲットフレームワークを.NET 6.0にする手順を紹介します。
概要
WinUI3 アプリケーションのターゲットフレームワークを.NET 6.0に変更する場合は、プロジェクトファイルのコード編集で
TargetFramework
タグの値を変更する方法か、
プロジェクトのプロパティ設定画面で変更する方法があります。
プロジェクトファイルのコードを編集する
プロジェクトファイルのコードを編集する場合は、
TargetFramework
タグの値を
net6.0-windows10.0.19041.0
または
net6.0-windows10.0.20348.0
に変更します。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>UnpackagedBlankApp</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
<WindowsPackageType>None</WindowsPackageType>
</PropertyGroup>
<ItemGroup>
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Assets\StoreLogo.png" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0-preview3" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.20348.19" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>UnpackagedBlankAppDotNet6</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
<WindowsPackageType>None</WindowsPackageType>
</PropertyGroup>
<ItemGroup>
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Assets\StoreLogo.png" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0-preview3" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.20348.19" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>
</Project>
プロジェクトのプロパティ画面で編集する
プロジェクトのプロパティ画面で編集する場合は、[アプリケーション]の[全般]のセクションの"ターゲットフレームワーク"を".NET 6.0"に設定し、"ターゲット OS バージョン"の値を
"10.0.19041.0" 以上の値に設定します。
著者
iPentecのメインプログラマー
C#, ASP.NET の開発がメイン、少し前まではDelphiを愛用
最終更新日: 2022-08-09
作成日: 2021-11-07