Search code examples
.netxamlcsprojwinui-3.net-8.0

RuntimeIdentifier is not recognized using .NET 8


I would like to create a new WinUI 3 desktop application using .NET 8. After I initialze the project in Visual Studio, the project is on .NET 6. I change the .csproj file's TargetFramework from net6.0-windows10.0.19041.0 to net8.0-windows10.0.19041.0, but this error pops up. How can I solve this issuewith .NET 8?

The errors:

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

My .csproj file:

<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>

I have tried with .NET 7 and it worked:

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

With .NET 8 it doesn't.


Solution

  • Well, after a bit of searching, I found the solution, that works for me.

    The official Microsoft documentation says:

    Use portable RIDs, for example, linux-<arch>, linux-musl-<arch>, osx-<arch>, and win-<arch>.

    So I changed the RuntimeIdentifiers and the PublishProfile.

    The "10" had to be removed. Like win10-x64 to win-x64.

    My modified .csproj is the following:

    <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>