Missing NETSDK1206 warning
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Describe the bug
.NET SDK 8 uses a [smaller RID graph](https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/rid-graph) than previous SDK versions. If a project contains a reference to a package with runtime identifiers no longer supported by .NET SDK 8, a [NETSDK1206](https://learn.microsoft.com/en-us/dotnet/core/tools/sdk-errors/netsdk1206) warning is reported when building. Example:
```
dotnet build --no-incremental .\Mmi2Project.csproj
Determining projects to restore...
All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\8.0.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(284,5): warning NETSDK1206: Found version-specific or distribution-specific runtime identifier(s): win10-x64, win10-x86, win7-x64, win7-x86, win8-x64, win8-x86, win81-x64, win81-x86. Affected libraries: Microsoft.Management.Infrastructure.Runtime.Win. 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. [C:\Users\WDAGUtilityAccount\Documents\Mmi2Project\Mmi2Project.csproj]
Mmi2Project -> C:\Users\WDAGUtilityAccount\Documents\Mmi2Project\bin\Debug\net8.0\Mmi2Project.dll
```
However, if a runtime identifier is appended to the build command, e.g. `--runtime win-x64`, no NETSDK1206 warning is reported even though the specified RID does not match any of the RIDs supported by the incompatible package. This is a problem because the warning would help identify package compatibility issues, and detect errors during build time before they occur in runtime.
### To Reproduce
1. Clean Windows Sandbox
2. Install .NET SDK 8.0.403
3. `dotnet new console -n Mmi2Project`
4. `cd Mmi2Project`
5. `dotnet add package Microsoft.Management.Infrastructure --version 2.0.0`
6. `dotnet build --no-incremental .\Mmi2Project.csproj --runtime win-x64`
#### Expected result
A NETSDK1206 warning is reported.
#### Actual result
No NETSDK1206 warning is reported.
### Further technical details
```
dotnet --info
.NET SDK:
Version: 8.0.403
Commit: c64aa40a71
Workload version: 8.0.400-manifests.18f19b92
MSBuild version: 17.11.9+a69bbaaf5
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.403\
.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.
Host:
Version: 8.0.10
Architecture: x64
Commit: 81cabf2857
.NET SDKs installed:
8.0.403 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.