Skip to content

NU1511 warnings/errors for test projects with .NET 10 SDK #112729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tmds opened this issue Feb 20, 2025 · 4 comments
Open

NU1511 warnings/errors for test projects with .NET 10 SDK #112729

tmds opened this issue Feb 20, 2025 · 4 comments
Labels
area-System.Text.Json untriaged New issue has not been triaged by the area owner

Comments

@tmds
Copy link
Member

tmds commented Feb 20, 2025

Some of our CI jobs that use a daily SDK build are failing. The SDK emits warnings for unused packages, and these warnings are then turned into errors.

See dotnet/core#9752 for info about the pruning warnings.

For example:

/home/tester/runtime/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/System.Text.RegularExpressions.Tests.csproj : error NU1510: Warning As Error: PackageReference Microsoft.VisualBasic will not be pruned. Consider removing this package from your dependencies, as it is likely unnecessary. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/System.Text.RegularExpressions.Tests.csproj : error NU1510: Warning As Error: PackageReference System.Formats.Asn1 will not be pruned. Consider removing this package from your dependencies, as it is likely unnecessary. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.Text.Json. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.IO.Pipelines. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.Linq.AsyncEnumerable. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/System.Text.Json.SourceGeneration.Roslyn4.4.Unit.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.IO.Pipelines. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/System.Text.Json.SourceGeneration.Roslyn4.4.Unit.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.Reflection.Metadata. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/System.Text.Json.SourceGeneration.Roslyn4.4.Unit.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.Text.Json. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.IO.Pipelines. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.Reflection.Metadata. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.Text.Json. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Roslyn4.4.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.Text.Json. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Roslyn3.11.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.Text.Json. [/home/tester/runtime/Build.proj]
/home/tester/runtime/src/libraries/System.Runtime/tests/System.Text.Encoding.Tests/System.Text.Encoding.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.IO.Pipelines. [/home/tester/runtime/Build.proj]
...

cc @ViktorHofer @nkolev92 @omajid

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Feb 20, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

@ViktorHofer
Copy link
Member

Thanks for the ping. This will now also show up in #112730 and we will handle it there.

@tmds
Copy link
Member Author

tmds commented May 12, 2025

@ViktorHofer this issue was fixed, but I'm seeing a new instance:

src/libraries/System.Net.ServerSentEvents/tests/System.Net.ServerSentEvents.Tests.csproj : error NU1511: Warning As Error: A ProjectReference cannot be pruned, System.Net.ServerSentEvents.

This is when building the runtime repo with a 10.0.100-preview.5.25258.26 SDK. It may be due to the newer SDK.

Additionally, even though my build invocation has --warnAsError false, this causes the build to fail with an error.

@ViktorHofer
Copy link
Member

ViktorHofer commented May 12, 2025

Interesting. That library got moved inbox with 478cfe2 and dotnet/runtime uses an SDK that includes that commit. But we only then only later added the library to PackageOverrides.txt which is the input to NuGet package pruning: 819bff1

We have a tracking issue to auto-generate the PackageOverrides.txt file so that it keeps in sync with its inputs: #113984

So this needs to be fixed for runtime and would show up for us as well in the next SDK upgrade. It doesn't show up in source-build's stage2 build because we don't build tests there. A blind spot.

I submitted #115470 to fix this in runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Text.Json untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

2 participants