Skip to content

fix(migrate): bump Nuke→Fallout PackageReference versions + strip stale Cryptography.Xml pin (#217)#226

Merged
ChrisonSimtian merged 1 commit into
mainfrom
fix/migrate-bump-fallout-version-and-strip-cryptography-xml
May 27, 2026
Merged

fix(migrate): bump Nuke→Fallout PackageReference versions + strip stale Cryptography.Xml pin (#217)#226
ChrisonSimtian merged 1 commit into
mainfrom
fix/migrate-bump-fallout-version-and-strip-cryptography-xml

Conversation

@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

Summary

Closes #217, reported by @dennisdoomen while migrating FluentAssertions to Fallout.

After `fallout-migrate`, the generated `_build.csproj` failed to restore with:

```
error NU1603: Warning As Error: _build depends on Fallout.Common (>= 10.1.0) but Fallout.Common 10.1.0 was not found. Fallout.Common 10.2.12 was resolved instead.
error NU1605: Warning As Error: Detected package downgrade: System.Security.Cryptography.Xml from 10.0.6 to 9.0.15.
```

Two root causes, both fixed here:

  1. NUKE-era `Version="10.1.0"` pins survived the namespace rewrite. `fallout-migrate` only ran a `Nuke.X` → `Fallout.X` Include attribute swap; the `Version="..."` attribute on the same `` element was untouched. Result: `` in the output — but `Fallout.Common 10.1.0` was never published (oldest is `10.2.12`). NuGet's NU1603 fallback + `WarningsAsErrors` in the migrated csproj escalated to fatal.
  2. Stale `System.Security.Cryptography.Xml` direct pin. NUKE-era projects often pinned an older major (9.x). Fallout.Common's transitive requirement is `≥ 10.0.6`, so the explicit pin produces NU1605 ("Detected package downgrade"). Dennis's manual workaround was to remove the pin entirely.

What this PR changes

`src/Fallout.Migrate/CsprojRewriter.cs` — two new regex passes:

  • `NukePackageWithInlineVersionPattern` — combined rewrite for `<PackageReference Include="Nuke.X" ... Version="Y" />`. Tolerates extra attrs like `PrivateAssets="all"` between Include and Version. Replaces both the Include namespace AND the Version pin to the running migrate tool's own version.
  • `CryptographyXmlPackageRefPattern` — strips explicit `System.Security.Cryptography.Xml` PackageReferences entirely. Lets Fallout.Common's transitive version win.

Existing namespace-only `PackageReferencePattern` still handles CPM-managed references (no inline Version — version lives in `Directory.Packages.props`), so we don't accidentally inject a Version where there wasn't one.

`src/Fallout.Migrate/Migration.cs` — `RewriteCsprojs` derives `falloutVersion` from `AssemblyInformationalVersionAttribute` (stripping the `+gabc...` build-metadata suffix). Inlined to keep `Fallout.Migrate` dependency-free (it has no ProjectReferences today). Falls back to a hardcoded `11.0.0` for local dev builds.

`tests/Fallout.Migrate.Tests/CsprojRewriterTest.cs` — 4 existing tests updated to pass the new `falloutVersion` parameter (no behavioural change for them) + 5 new tests covering:

  • `BumpsNukeInlineVersionToCurrentFalloutVersion` — direct regression guard for Fallout-migrate triggers some dependency confusion #217.
  • `BumpsVersionAcrossExtraAttributesBetweenIncludeAndVersion` — `PrivateAssets="all"` between Include and Version still works.
  • `LeavesCpmManagedReferencesWithoutInlineVersionUntouchedByVersionPass` — no Version-injection where the user didn't have one.
  • `StripsSystemSecurityCryptographyXmlPackageReference` — the second sub-bug.
  • `LeavesOtherSystemPackagesAlone` — only Cryptography.Xml is targeted; other System.* are not touched.

`CHANGELOG.md` — entry added under `[Unreleased] — 11.0` alongside existing bug-fix bullets.

Test plan

  • CI green (Fallout.Migrate.Tests: 22/22 locally; was 17/17 before).
  • After merge, Dennis re-runs `fallout-migrate` on FluentAssertions and the migrated `_build.csproj` restores without NU1603 / NU1605.

Refs

…le Cryptography.Xml pin

Closes #217 (reported by @dennisdoomen migrating FluentAssertions).

The Nuke.X → Fallout.X namespace rewrite carried the original NUKE
`Version="10.1.0"` pins onto `Fallout.*` packages. But `Fallout.*` was
never published at 10.1.0 (oldest is 10.2.12), so NuGet hit NU1603
("not found, falling back to next-higher") and `WarningsAsErrors` in the
migrated project escalated the warning to fatal.

CsprojRewriter changes:
  - New `NukePackageWithInlineVersionPattern` runs first, matching the
    full `<PackageReference Include="Nuke.X" ... Version="Y" />` shape
    (tolerates `PrivateAssets="..."` etc. between Include and Version)
    and rewrites BOTH the namespace AND the version in one pass.
  - Existing namespace-only `PackageReferencePattern` still handles
    CPM-managed references (no inline Version — version lives in
    Directory.Packages.props), so we don't accidentally inject a Version
    where there wasn't one.
  - New `CryptographyXmlPackageRefPattern` removes explicit
    `System.Security.Cryptography.Xml` `<PackageReference>` lines.
    NUKE-era projects often pinned older majors (9.x) that conflict
    with `Fallout.Common`'s transitive ≥ 10.0.6 → NU1605 downgrade.
    Stripping the explicit pin lets the transitive version win, which
    matches Dennis's manual workaround.

Migration.ResolveFalloutVersion inlines a small InformationalVersion
reader (instead of pulling in Fallout.Utilities just for GetVersionText)
so the migrate tool stays dependency-free. Falls back to a hardcoded
`11.0.0` for local dev builds where InformationalVersion has no
git-height `+` suffix.

CHANGELOG entry added under [Unreleased] — 11.0 alongside the existing
bug-fix bullets.

Tests:
  - 4 existing CsprojRewriterTest cases updated to pass the new
    `falloutVersion` parameter (no behaviour change for them).
  - 5 new tests: BumpsNukeInlineVersionToCurrentFalloutVersion,
    BumpsVersionAcrossExtraAttributesBetweenIncludeAndVersion,
    LeavesCpmManagedReferencesWithoutInlineVersionUntouchedByVersionPass,
    StripsSystemSecurityCryptographyXmlPackageReference,
    LeavesOtherSystemPackagesAlone.
  - Fallout.Migrate.Tests: 22/22 passed locally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ChrisonSimtian
ChrisonSimtian merged commit ee31e06 into main May 27, 2026
2 checks passed
@ChrisonSimtian
ChrisonSimtian deleted the fix/migrate-bump-fallout-version-and-strip-cryptography-xml branch May 27, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fallout-migrate triggers some dependency confusion

1 participant