Skip to content

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

Closed

Description

@tmds

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

Activity

  1. dotnet-policy-service commented on Feb 20, 2025

    @dotnet-policy-service
    Contributor

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

  2. ViktorHofer commented on Feb 20, 2025

    @ViktorHofer
    Member

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

  3. tmds commented on May 12, 2025

    @tmds
    MemberAuthor

    @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.

  4. ViktorHofer commented on May 12, 2025

    @ViktorHofer
    Member

    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.

  5. tmds commented on May 16, 2025

    @tmds
    MemberAuthor

    Fixed by #115470.

  6. locked and limited conversation to collaborators on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions