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

错误:

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>

我try 了.NET 7,它起作用了:

<TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>

而在.NET8中则不是这样.

推荐答案

请try 以下步骤升级到.NET 8:

  1. 下载并安装.NET 8 SDK.

  2. 编辑*.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的后续版本中进行更改/改进.从发行说明中勾选this.

.net相关问答推荐

.NET最小API BadRequest响应不返回正文

如何将 signalR 添加到不同项目中的后台服务?

如何运行大量阻塞/同步 I/O 操作

如何使用 C# 关键字作为属性名称?

在 WPF 窗口中获取当前聚焦的元素/控件

为什么 .NET 中没有可序列化 XML 的字典?

无法加载文件或程序集WebGrease,版本=1.5.1.25624,Culture=neutral,PublicKeyToken=31bf3856ad364e35或其依赖项之一

.Net 中的 Int128?

处理序列没有元素异常

C#:获得完整的桌面大小?

新的 netstandardapp 和 netcoreapp TFM 有什么区别?

Await 运算符只能在 Async 方法中使用

是否有 Linq 方法可以将单个项目添加到 IEnumerable

ToLowerInvariant() 有什么问题?

获取系统中已安装的应用程序

C# 应用程序中的全局键盘捕获

WPF 中的 Application.DoEvents() 在哪里?

如何在我的机器上找到 fuslogvw.exe?

如何使用 XmlSerializer 将字符串序列化为 CDATA?

无法添加对 dll 的引用