microsoft / microsoft-ui-xaml

WinUI: a modern UI framework with a rich set of controls and styles to build dynamic and high-performing Windows applications.
MIT License
6.37k stars 683 forks source link

[WindowsAppSDK + .NET8] Getting warning "Found version-specific or distribution-specific runtime identifier(s): win10-arm64, win10-x64, win10-x86. Affected libraries: Microsoft.WindowsAppSDK." #9107

Closed DierkDroth closed 1 year ago

DierkDroth commented 1 year ago

Describe the bug

I just upgraded my WindowsAppSDK project to latest .NET8 and now am getting this warning

C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(284,5): warning NETSDK1206: Found version-specific or distribution-specific runtime identifier(s): win10-arm64, win10-x64, win10-x86. Affected libraries: Microsoft.WindowsAppSDK. In .NET 8.0 and higher, assets for version-specific and distribution-specific runtime identifiers will not be found by default. See https://aka.ms/dotnet/rid-usage for details.

I have this in my project file

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
    <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
    <RootNamespace>Unusual.Windows</RootNamespace>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <Platforms>x86;x64;arm64</Platforms>
    <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
    <UseWinUI>true</UseWinUI>
    <EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
    <PackageCertificateThumbprint>48ed018aa6aae0c5bad88252a60201b47a770122</PackageCertificateThumbprint>
    <AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
    <RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
    <EnableNETAnalyzers>false</EnableNETAnalyzers>
    <ProduceReferenceAssembly>False</ProduceReferenceAssembly>
    <DefaultLanguage>en-US</DefaultLanguage>
    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
    <GeneratePackageOnBuild>False</GeneratePackageOnBuild>
    <RunAnalyzersDuringLiveAnalysis>False</RunAnalyzersDuringLiveAnalysis>
    <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
  </PropertyGroup>

Related?

How could that issue be resolved?

Steps to reproduce the bug

Please see above

Expected behavior

WindowsAppSDK project should build in .NET8 as it did in .NET7

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.4.2: 1.4.231008000

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

remokeitel commented 1 year ago

Does it help if you change <EnablePreviewMsixTooling>true</EnablePreviewMsixTooling> to <EnableMsixTooling>true</EnableMsixTooling>? Also update Microsoft.WindowsAppSDK NuGet package, clean the solution and delete bin and obj folders of the project, then rebuild.

DierkDroth commented 1 year ago

@remokeitel thanks for your feedback.

Yes, I'm on latest NuGet package and already cleaned up the solution a couple of time: the problem persists. The warning suggests that the WindowAppSDK NuGet just it 'not ready yet' for .NET8. I certainly could just disable the warning, but that would not resolve the issue which is within the WindowsAppSDDK NuGet itself.

kmgallahan commented 1 year ago

In the WinUI project -> Properties -> PublishProfiles -> change every instance of win10 to win, including in the file names

I'd recommend doing a solution search for "win10" to ensure you don't miss anything.

DierkDroth commented 1 year ago

Thanks for your feedback @kmgallahan.

I can't seem to find the option you mentioned (please see screenshot). Where would I find that?

Also: I already tweaked all my *.csproj files to replace win10by win(please see my original) post, because I could not compile at all my solution at all after upgrading to .NET 8. Now, it gives my warnings (as per my original post) but build and runs. Still like to see resolved the cause of the warnings...

image
brandonw3612 commented 1 year ago

As is described in the warning message, version-specific or distribution-specific runtime identifiers won't be found by the .NET SDK by default. Even after updating the .csproj file by changing the identifiers to win-ARCH, however, the upstream WinAppSDK package has not got ready for .NET 8, and that's where the warning message came from.

Currently I'm also upgrading a couple of my WinAppSDK projects to .NET 8, (the LTS version, of course). One possible workaround for this would be to add a UseRidGraph field to the project file.

<UseRidGraph>true</UseRidGraph>

Here is a reference to that, as stated in the breaking changes of .NET 8.

DierkDroth commented 1 year ago

Thanks @brandonw3612.

In fact I came across the article you referenced before, but was shying away to apply any 'backward compatible' changes to my solution, since I found it hard to believe that Microsoft did not prepare their own WindowsAppSDK as they rolled .NET8 last week. Oh well...

In any case: your suggested change got me rid of the warnings. Hopefully it does not bring unwanted side affects ... we'll see. Thanks again

DarranRowe commented 1 year ago

Well, we haven't been seeing any of the 1.5 preview releases yet, and 1.4.3 isn't a good place for adding .NET 8 support. I also wonder about the status of Cs/WinRT and Native AOT support. Getting the Windows App SDK WinRT projection .NET 8 compatible is one thing, but I feel that it would be tough pushing Native AOT back to 1.6.

remokeitel commented 1 year ago

I don't use <UseRidGraph>true</UseRidGraph> and don't get any warnings. I upgraded my Windows App SDK project at last weekend to .NET 8 with changing identifiers from win10-xxx to win-xxx. There would be another issue in your project.

DarranRowe commented 1 year ago

@remokeitel Do you use <RuntimeHostConfigurationOption Include="System.Runtime.Loader.UseRidGraph" Value="true" />? This is seen as the same thing. Without this, the build process will output: 1>C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(284,5): warning NETSDK1206: Found version-specific or distribution-specific runtime identifier(s): win10-arm64, win10-x64, win10-x86. Affected libraries: Microsoft.WindowsAppSDK. In .NET 8.0 and higher, assets for version-specific and distribution-specific runtime identifiers will not be found by default. See https://aka.ms/dotnet/rid-usage for details. It is also understandable, for example, the bootstrapper is in a win10 rid named directory. If you don't see that, consider the fact that it may be a template issue. Maybe the WinUI 3 with packaging may not show this.

remokeitel commented 1 year ago

@DarranRowe No, I don't use this option. There is no warning regarding runtime identifiers.

DarranRowe commented 1 year ago

Screenshot 2023-11-21 021122

So it is a project template thing. This seems to be related to the fact that the separate packaging project does the publish as a separate step. Having the package generation as part of the same process seems to bypass something.

Scottj1s commented 10 months ago

@DierkDroth thanks for your patience - the next servicing release of Windows App SDK, 1.4.4, will be out shortly and the UseRidGraph workaround will no longer be necessary. @DarranRowe support for NativeAOT is nearly complete in both C#/WinRT and Windows App SDK and we intend to deliver that with Windows App SDK 1.5.

DierkDroth commented 10 months ago

Thanks for the update @Scottj1s

vec715 commented 4 months ago

Any updates on how to solve this issue? It still persists as of June 2024