The logic in https://github.com/dotnet/dotnet/blob/main/repos/runtime.proj#L10-L13 forces x64 RIDs if Windows, FreeBSD or Mac are detected. This overrides any value set in /p:TargetRid.
Fixing the conditionals to allow the override to override on Mac then fails when cross-building on x64 with
/Users/directhex/Projects/dotnet/.dotnet/sdk/7.0.100-rc.2.22477.23/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the PublishReadyToRun property to false, or use a supported runtime identifier when publishing. When targeting .NET 6 or higher, make sure to restore packages with the PublishReadyToRun property set to true. [/Users/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
It doesn't fail on a native arm64 build (though within devdiv, we do all our builds on x64 so need to be able to do cross-compiling)
The logic in https://github.com/dotnet/dotnet/blob/main/repos/runtime.proj#L10-L13 forces x64 RIDs if Windows, FreeBSD or Mac are detected. This overrides any value set in
/p:TargetRid.Fixing the conditionals to allow the override to override on Mac then fails when cross-building on x64 with
/Users/directhex/Projects/dotnet/.dotnet/sdk/7.0.100-rc.2.22477.23/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the PublishReadyToRun property to false, or use a supported runtime identifier when publishing. When targeting .NET 6 or higher, make sure to restore packages with the PublishReadyToRun property set to true. [/Users/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]It doesn't fail on a native arm64 build (though within devdiv, we do all our builds on x64 so need to be able to do cross-compiling)