Description
Is your feature request related to a problem? Please describe.
We are upgrading a solution from .NET 6 to .NET 8. After the upgrade we started getting NETSDK1206 warning for one of the packages (Microsoft.Azure.DocumentDB.Core
), which we decided to suppress for now. But it seems like that warning can only be suppressed at project level, while we would like to suppress it for just that one package. We want to make sure that if at any point going forward another package with the same issue gets introduced, we would not overlook it.
Repro
Project file, foo.csproj
:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.22.0" />
</ItemGroup>
</Project>
Build & warning (formatted a bit):
> dotnet build foo.csproj
Restore complete (0.2s)
foo succeeded with 1 warning(s) (1.5s) → bin\Debug\net9.0\foo.dll
C:\Program Files\dotnet\sdk\9.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(322,5):
warning NETSDK1206: Found version-specific or distribution-specific runtime identifier(s): win7-x64.
Affected libraries: Microsoft.Azure.DocumentDB.Core. 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.
Build succeeded with 1 warning(s) in 2.2s
Can be suppressed with project-level NoWarn
Project file, foo.csproj
:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<NoWarn>NETSDK1206</NoWarn> <!-- added -->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.22.0" />
</ItemGroup>
</Project>
Build:
> dotnet build foo.csproj
Restore complete (0.3s)
foo succeeded (0.3s) → bin\Debug\net9.0\foo.dll
Build succeeded in 1.1s
Package-level NoWarn
is ignored
Project file, foo.csproj
:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.22.0" NoWarn="NETSDK1206" /> <!-- added: NoWarn -->
</ItemGroup>
</Project>
Build & warning (formatted a bit):
> dotnet build foo.csproj
Restore complete (0.3s)
foo succeeded with 1 warning(s) (0.3s) → bin\Debug\net9.0\foo.dll
C:\Program Files\dotnet\sdk\9.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(322,5):
warning NETSDK1206: Found version-specific or distribution-specific runtime identifier(s): win7-x64.
Affected libraries: Microsoft.Azure.DocumentDB.Core. 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.
Build succeeded with 1 warning(s) in 1.0s
Describe the solution you'd like
We would like to have a way to suppress NETSDK1206
at package level, either through NoWarn
attribute on PackageReference
element, or through other means.
Glancing through other .NET SDK warnings, there are some that apply to specific packages - it might make sense to implement package-level NoWarn
support for all such warnings.