Skip to content

Bump NuGet.Packaging to 7.9.0 to match the SDK's NuGet version - #677

Merged
dennisdoomen merged 3 commits into
Fallout-build:developfrom
dennisdoomen:fix/nuget-packaging-7x-nonbreaking
Sep 25, 2026
Merged

dennisdoomen merged 3 commits into
Fallout-build:developfrom
dennisdoomen:fix/nuget-packaging-7x-nonbreaking

Conversation

@dennisdoomen

@dennisdoomen dennisdoomen commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #638.

What changed

NuGet.Packaging 6.14.3 → 7.9.0 in Directory.Packages.props, plus two NoWarn entries for the NU1701 warning this creates. Also pins NuGet.Protocol and NuGet.Resolver to 7.9.0 (see below). No target framework changes, no public API changes.

Why

The .NET 10 SDK loads NuGet.Frameworks 7.9.0.0 into the MSBuild process. The pinned NuGet.Packaging 6.14.3 loads NuGet.Frameworks 6.14.3 into that same process, so every ./build.sh run fails at Compile on SDK 10.0.400 with:

InvalidProjectFileException: The expression "[MSBuild]::GetTargetFrameworkIdentifier(net10.0)" cannot be evaluated. Could not load file or assembly 'NuGet.Frameworks, Version=7.9.0.0'.

NuGet 7.0 only removed APIs that were already marked obsolete. This repo uses NuspecReader, PackageArchiveReader, PackageFolderReader, VersionRange, NuGetVersion, and NuGetFramework. None of them changed.

NuGet 7.x no longer ships a netstandard2.0 build. Fallout.Tooling and Fallout.SourceGenerators still target netstandard2.0, so restoring them now pulls in .NET Framework compatibility assets instead and emits NU1701. That is a warning, not an error. Both NoWarn additions in this PR just silence it. No target framework is removed and no consumer-facing behavior changes.

The NuGet.Protocol / NuGet.Resolver pin

The first version of this PR broke all 14 tests in Fallout.Migrate.Analyzers.Specs with System.MethodAccessException on NuGet.Frameworks.NuGetFrameworkFullComparer..ctor().

Those specs use Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit 1.1.2, which pins its Microsoft.CodeAnalysis.Analyzer.Testing dependency to exactly 1.1.2. That package in turn pins NuGet.Protocol and NuGet.Resolver to 6.3.4. Bumping NuGet.Packaging to 7.9.0 moved every package below it (NuGet.Common, NuGet.Configuration, NuGet.Frameworks, NuGet.Versioning) up to 7.9.0 through central transitive pinning, since they are dependencies of NuGet.Packaging. NuGet.Protocol and NuGet.Resolver depend on NuGet.Packaging instead of the other way round, so transitive pinning does not touch them, and they stayed at 6.3.4. Microsoft.CodeAnalysis.Testing's ReferenceAssemblies helper resolves packages over NuGet.Protocol at test time, so it now called into a NuGet.Frameworks build whose member accessibility no longer matched what the 6.3.4 build of NuGet.Protocol expected. That is the source of the MethodAccessException.

There is no newer version of Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit to pick up a matching NuGet.Protocol version. Its nuspec pins Microsoft.CodeAnalysis.Analyzer.Testing to the exact range [1.1.2, 1.1.2], so a central override cannot bump the base package either. Pinning NuGet.Protocol and NuGet.Resolver to 7.9.0 directly in Directory.Packages.props is the only way to unify the whole NuGet.* family, and CentralPackageTransitivePinningEnabled picks up both pins with no other project changes needed.

Relation to #639

#639 carries the same version bump but treats it as a breaking change. It uses target/vNext instead of target/vCurrent and holds the fix for next year's major, reasoning that netstandard2.0 support is going away. This PR keeps every netstandard2.0 target as-is. The warning is cosmetic, so this can ship now as an ordinary bug fix and close #638 immediately instead of waiting for the next major.

Verification

  • ./build.sh Compile fails on SDK 10.0.400 without this change, succeeds with it.
  • dotnet test tests/Fallout.Migrate.Analyzers.Specs : 14/14 pass (all 14 failed before the NuGet.Protocol/NuGet.Resolver pin was added).
  • dotnet restore fallout.slnx: clean, no new warnings.

I've also verified this end-to-end against a real consumer:

  1. Created a local version of the Fallout NuGet packages with the changes in this PR.

  2. First reproduced the issue in FluentAssertions by removing the <PackageReference Include="NuGet.Frameworks" Version="7.9.0" /> on .NET SDK 10.0.400. Note that I had to downgrade from 10.0.401 to 10.0.400 to reproduce it. This gave me

    InvalidProjectFileException: The expression "[MSBuild]::GetTargetFrameworkIdentifier(net8.0)" cannot be evaluated. Could not load file or assembly 'NuGet.Frameworks, Version=7.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The located assembly's manifest definition does not match the assembly reference. (0x80131040) C:\Program Files\dotnet\sdk\10.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets

  3. Bumped the Fallout.Common and Fallout.Components references to the locally built pre-release Fallout packages.

  4. Verified that the error went away.

🤖 Partially generated with Claude Code

The .NET 10 SDK loads NuGet.Frameworks 7.9.0.0 into MSBuild. The pinned
NuGet.Packaging 6.14.3 loaded NuGet.Frameworks 6.14.3 into the same build-host
process, so every ./build.sh run failed at Compile once CI moved from SDK
10.0.302 to 10.0.400:

  InvalidProjectFileException: The expression
  "[MSBuild]::GetTargetFrameworkIdentifier(net10.0)" cannot be evaluated.
  Could not load file or assembly 'NuGet.Frameworks, Version=7.9.0.0'.

NuGet 7.0 only removed APIs that were already obsolete. This repo uses
NuspecReader, PackageArchiveReader, PackageFolderReader, VersionRange,
NuGetVersion and NuGetFramework, none of which changed.

NuGet 7.x drops netstandard2.0. Fallout.Tooling and Fallout.Tooling.Generator
still target it, so those legs now restore .NET Framework assets and emit
NU1701. That is a warning, not an error, and is tracked in the issue.

Closes Fallout-build#638

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dennisdoomen dennisdoomen added bug Something isn't working target/vCurrent Targets the current version labels Sep 19, 2026
@dennisdoomen
dennisdoomen marked this pull request as ready for review September 19, 2026 13:45
@dennisdoomen
dennisdoomen requested a review from a team as a code owner September 19, 2026 13:45
@dennisdoomen
dennisdoomen marked this pull request as draft September 19, 2026 13:52
Bumping NuGet.Packaging to 7.9.0 let central transitive pinning carry
NuGet.Common, NuGet.Configuration, NuGet.Frameworks, and NuGet.Versioning
up to 7.9.0 too, since they're dependencies of NuGet.Packaging. NuGet.Protocol
and NuGet.Resolver sit on the other side of that dependency edge (they depend
on NuGet.Packaging, not the reverse), so transitive pinning left them at the
6.3.4 pulled in by Microsoft.CodeAnalysis.Analyzer.Testing 1.1.2.

That mismatch broke every Fallout.Migrate.Analyzers.Specs test at runtime:
NuGet.Protocol 6.3.4 calls NuGet.Frameworks.NuGetFrameworkFullComparer's
constructor expecting its old accessibility, throws MethodAccessException
against the loaded 7.9.0 build, and Microsoft.CodeAnalysis.Testing's
ReferenceAssemblies helper (which resolves packages over NuGet.Protocol at
test time) fails before any test body runs.

Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit has no release past
1.1.2, and that version hard-pins Microsoft.CodeAnalysis.Analyzer.Testing to
exactly 1.1.2 ([1.1.2, 1.1.2]), so there's no newer version to pick up a
matching NuGet.Protocol. Pinning it centrally alongside NuGet.Packaging is
the only lever available.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ing-7x-nonbreaking

# Conflicts:
#	Directory.Packages.props
@dennisdoomen
dennisdoomen enabled auto-merge (squash) September 25, 2026 06:19
@dennisdoomen
dennisdoomen merged commit 68e637e into Fallout-build:develop Sep 25, 2026
1 check passed
@dennisdoomen
dennisdoomen deleted the fix/nuget-packaging-7x-nonbreaking branch September 25, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working target/vCurrent Targets the current version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build fails on .NET SDK 10.0.400: NuGet.Packaging 6.14.3 conflicts with the SDK's NuGet 7.x

2 participants