XAML 使用.NET 8无法识别RuntimeIdentifier

kgqe7b3p  于 11个月前  发布在  .NET
关注(0)|答案(2)|浏览(229)

我想使用.NET 8创建一个新的WinUI 3桌面应用程序。在Visual Studio中初始化该项目后,该项目位于.NET 6上。我将.csproj文件的TargetFramework从net6.0-windows10.0.19041.0更改为net8.0-windows10.0.19041.0,但弹出此错误。如何使用.NET 8解决此问题?
错误:

NETSDK1083: The specified RuntimeIdentifier "win10-x86" is not recognized
NETSDK1083: The specified RuntimeIdentifier "win10-x64" is not recognized
NETSDK1083: The specified RuntimeIdentifier "win10-arm64" is not recognized

字符串
我的.csproj文件:

<PropertyGroup>
  <OutputType>WinExe</OutputType>
  <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
  <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
  <RootNamespace>SudokuEngineApp</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>
  <EnableMsixTooling>true</EnableMsixTooling>
</PropertyGroup>


我尝试过.NET 7,它工作了:
<TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
而.NET 8则不是。

tyky79it

tyky79it1#

好吧,经过一段时间的搜索,我找到了解决方案,这对我来说很有效。
official Microsoft documentation说道:
使用可移植RID,例如linux-<arch>linux-musl-<arch>osx-<arch>win-<arch>
所以我改变了RuntimeIdentifiersPublishProfile
必须删除“10”,比如win10-x64win-x64
修改后的.csproj如下:

<PropertyGroup>
  <OutputType>WinExe</OutputType>
  <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
  <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
  <RootNamespace>SudokuEngineApp</RootNamespace>
  <ApplicationManifest>app.manifest</ApplicationManifest>
  <Platforms>x86;x64;ARM64</Platforms>
  <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
  <PublishProfile>win-$(Platform).pubxml</PublishProfile>
  <UseWinUI>true</UseWinUI>
  <EnableMsixTooling>true</EnableMsixTooling>
</PropertyGroup>

字符串

n9vozmp4

n9vozmp42#

尝试以下步骤升级到.NET 8:
1.下载并安装.NET 8 SDK

  • 编辑 *.csproj文件。
  • TargetFramework:net8.0-windows10.0.19041.0
  • RuntimeIdentifiers:win-x86;win-x64;win-arm64
  • PublishProfile:win-$(Platform).pubxml
  • 添加UseRidGraph并将其设置为true

举例来说:

<PropertyGroup>
  <OutputType>WinExe</OutputType>
  <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
  <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
  <RootNamespace>WinUI3App</RootNamespace>
  <ApplicationManifest>app.manifest</ApplicationManifest>
  <Platforms>x86;x64;ARM64</Platforms>
  <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
  <PublishProfile>win-$(Platform).pubxml</PublishProfile>
  <UseRidGraph>true</UseRidGraph>
  <UseWinUI>true</UseWinUI>
  <EnableMsixTooling>true</EnableMsixTooling>
  <Nullable>enable</Nullable>
</PropertyGroup>

字符串
这些步骤可能会在WindowsAppSDK的后续版本中进行更改/改进,请查看发行说明。

相关问题