'.net version 6.0.300 Optimizing assemblies for performance is not supported for the selected target platform or architecture
When migrating from .net 5 to .net 6 I run into similar issue as described here https://github.com/dotnet/sdk/issues/24269, except in my case the build fails with NETSDK1095, instead of just printing warning. I pinned version to 6.0.201 with global.json. I was able to observe mentioned issue with version 6.0.300 on my local machine. With pinned version it went away. Assuming version 6.0.201 does not suffer mentioned regression.
I added step to install custom SDK in to the azure pipeline.
Than dotnet --version command prints out 6.0.201
Original pipeline looks like this
dotnet restoredotnet build -c Release --no-restoredotnet testdotnet publish -c Release --no-build -r "win10-x64" -p:PublishReadyToRun=true
And it is PublishReadyToRun=true which is causing an issue. When I added --self-contained it fixed it on 6.0.201 on localhost, but still fails in the pipe
It fails with error:
C:\hostedtoolcache\windows\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(293,5): error NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Please verify you are using a supported runtime identifier, or set the PublishReadyToRun property to false.
I ran it on windows-2019 and windows-2022 azure agents.
Anybody knows how to temporarily fix this issue?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
