dotnet / dotnet/sdk

Support suppression of package-specific NETSDK warnings on package level

Open
#46,181 9 comments 2 reactions 1 assignee Claimed by @baronfel View on GitHub
Area-NetSDK Partner request
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

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](https://learn.microsoft.com/en-us/dotnet/core/tools/sdk-errors/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`:
```xml


net9.0



```

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`:
```xml


net9.0
NETSDK1206



```

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`:
```xml


net9.0



```

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](https://learn.microsoft.com/en-us/dotnet/core/tools/sdk-errors/), there are some that apply to specific packages - it might make sense to implement package-level `NoWarn` support for all such warnings.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.