Skip to content

Test It_throws_a_warning_when_NuGetPackageRoot_is_empty fails on release/10.0.3xx due to NuGet 7.6 behavior change #54828

Description

@nagilson

Summary

The test It_throws_a_warning_when_NuGetPackageRoot_is_empty in GivenThatWeWantToUseFrameworkRoslyn.cs is consistently failing on all PRs targeting release/10.0.3xx for 11+ days. The test passes on main.

Details

The test expects NETSDK1221 to be emitted when NuGetPackageRoot is empty during combined /t:Restore;Build with Full Framework MSBuild. However, on the release/10.0.3xx SDK (which bundles NuGet 7.6.0), NuGetPackageRoot is no longer empty at evaluation time — it appears to be pre-populated from the NUGET_PACKAGES environment variable that the test sets.

On main (SDK 11.x, NuGet 7.9.0): NuGetPackageRoot is empty at evaluation → warning fires → test passes ✅
On release/10.0.3xx (SDK 10.0.3xx, NuGet 7.6.0): NuGetPackageRoot is NOT empty at evaluation → no warning → test fails ❌

Both use the same MSBuild 18.7.1 (VS 18 Insiders) on the Helix test machine. The SDK targets code is identical between branches.

Evidence

Root Cause Hypothesis

NuGet 7.6.0 (bundled in SDK 10.0.3xx) appears to initialize NuGetPackageRoot from the NUGET_PACKAGES environment variable during evaluation, which makes the property non-empty even for fresh projects with no .nuget.g.props. NuGet 7.9.0 (bundled on main) does not do this, preserving the old behavior where NuGetPackageRoot remains empty until .nuget.g.props is imported.

This means the underlying bug (issue #43016) may be fixed in NuGet 7.6.0, making the NETSDK1221 warning unnecessary in this scenario.

Possible Fixes

  1. Update the test to not set NUGET_PACKAGES env var (so NuGetPackageRoot is truly empty regardless of NuGet version)
  2. Condition the test on the NuGet version behavior
  3. Remove the test if the underlying issue is genuinely fixed by NuGet 7.6

Context

/cc @jjonescz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions