Skip to content

Recognizes version variables and updates the version accordingly#478

Open
IT-VBFK wants to merge 1 commit into
Fallout-build:mainfrom
IT-VBFK:fix/csproj-convert-version-var
Open

Recognizes version variables and updates the version accordingly#478
IT-VBFK wants to merge 1 commit into
Fallout-build:mainfrom
IT-VBFK:fix/csproj-convert-version-var

Conversation

@IT-VBFK

@IT-VBFK IT-VBFK commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Update Fallout.Migrate so that package versions referenced through MSBuild properties are migrated to the target Fallout version.

Previously, the .csproj rewriter handled package references with literal versions:

<PackageReference Include="Nuke.Common" Version="10.3.49" />

However, projects that shared a version through an MSBuild property were only partially migrated:

<PropertyGroup>
  <NukeVersion>10.3.49</NukeVersion>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="Nuke.Common" Version="$(NukeVersion)" />
  <PackageReference Include="Nuke.Components" Version="$(NukeVersion)" />
</ItemGroup>

The package IDs could be renamed to Fallout.*, while the property and its value remained on the old NUKE version.

This left the migrated project in an inconsistent state and could cause package restore or build failures.

Closes #477.

What changed

Distinguish literal versions from property-based versions

The inline package-version rewrite now excludes version values beginning with an MSBuild property expression such as:

Version="$(NukeVersion)"

This prevents the existing literal-version rewrite from replacing the property reference itself with an inline version.

Property-based version management therefore remains property-based after migration.

For example:

<PackageReference Include="Nuke.Common" Version="$(NukeVersion)" />

is processed by the property-aware migration flow instead of being flattened into:

<PackageReference Include="Fallout.Common" Version="11.0.0" />

Detect version properties used by package references

A new rewrite pass discovers MSBuild properties referenced by PackageReference version attributes:

<PackageReference Include="Nuke.Common" Version="$(PropertyName)" />

The referenced property names are deduplicated and used to locate the corresponding property elements in the project file.

Update referenced property values

For each discovered version property, the rewriter updates its value to the requested Fallout version.

A NUKE-specific version property is migrated completely.

Before:

<PropertyGroup>
  <NukeVersion>10.3.49</NukeVersion>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="Nuke.Common" Version="$(NukeVersion)" />
  <PackageReference Include="Nuke.Components" Version="$(NukeVersion)" />
</ItemGroup>

After:

<PropertyGroup>
  <FalloutVersion>11.0.0</FalloutVersion>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="Fallout.Common" Version="$(FalloutVersion)" />
  <PackageReference Include="Fallout.Components" Version="$(FalloutVersion)" />
</ItemGroup>

The existing MSBuild-property migration renames NukeVersion to FalloutVersion, while the new rewrite updates the property's value.

Preserve custom property names

Projects are not required to name their shared version property NukeVersion.

When a custom property is used, its name is preserved and only its value is updated.

Before:

<PropertyGroup>
  <CiProjectVersion>10.3.49</CiProjectVersion>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="Nuke.Common" Version="$(CiProjectVersion)" />
</ItemGroup>

After:

<PropertyGroup>
  <CiProjectVersion>11.0.0</CiProjectVersion>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="Fallout.Common" Version="$(CiProjectVersion)" />
</ItemGroup>

This keeps the project's existing version-management structure intact while ensuring that migrated Fallout packages use the correct version.

Leave unrelated properties untouched

Only properties referenced by a PackageReference version attribute are selected for updating.

Other version-like properties in the same project are left unchanged, avoiding broad replacements based solely on property names or values.

Migration behavior

Input Result
Literal package version Package ID and inline version are updated
Package version using $(NukeVersion) Property and references are renamed to FalloutVersion, and the property value is updated
Package version using a custom property The property name is preserved and its value is updated
Unreferenced property Left unchanged
Unrelated package reference Left unchanged

Tests

Added regression coverage for the scenarios reported in #477:

  • A shared NukeVersion property is renamed to FalloutVersion.
  • All package references using $(NukeVersion) are updated to use $(FalloutVersion).
  • The renamed property receives the requested Fallout version.
  • An arbitrary shared version property keeps its original name while its value is updated.
  • An unrelated, unreferenced property remains unchanged.
  • Multiple NUKE package references sharing the same property are migrated consistently.

Result

Running fallout-migrate now produces a consistent .csproj for projects that manage NUKE package versions through MSBuild properties.

Both the package references and the property supplying their version are migrated automatically, without requiring users to manually repair the project afterward.

🤖 helped out here :D

@IT-VBFK
IT-VBFK requested a review from a team as a code owner July 11, 2026 18:53
@ITaluone
ITaluone force-pushed the fix/csproj-convert-version-var branch from 2e73450 to 1391641 Compare July 11, 2026 18:53
@ITaluone
ITaluone requested a review from ChrisonSimtian July 11, 2026 18:54
@ITaluone ITaluone added enhancement New feature or request target/vCurrent Targets the current version labels Jul 11, 2026
@IT-VBFK
IT-VBFK force-pushed the fix/csproj-convert-version-var branch from f157a46 to 40c5ed9 Compare July 12, 2026 05:32
@ChrisonSimtian
ChrisonSimtian requested a review from Copilot July 12, 2026 08:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Fallout.Migrate’s .csproj rewrite logic to handle projects that pin Fallout/Nuke package versions via MSBuild properties (e.g., Version="$(NukeVersion)"), aligning with issue #477’s migration expectations.

Changes:

  • Refines the “inline literal version” rewrite to avoid consuming Version="$(...)" so variable-based versions can be handled separately.
  • Adds a new pass that discovers version variables used by PackageReferences and bumps the corresponding property values to the target Fallout version.
  • Extends specs to cover NukeVersionFalloutVersion renaming and arbitrary version-variable bumping behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/Fallout.Migrate/CsprojRewriter.cs Adds variable-aware version handling and bumps property-based versions to the target Fallout version.
tests/Fallout.Migrate.Specs/CsprojRewriterSpecs.cs Adds/adjusts specs to validate migration behavior for version variables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Fallout.Migrate/CsprojRewriter.cs
Comment thread src/Fallout.Migrate/CsprojRewriter.cs
Comment thread tests/Fallout.Migrate.Specs/CsprojRewriterSpecs.cs
@IT-VBFK
IT-VBFK requested a review from ChrisonSimtian July 12, 2026 11:51
@IT-VBFK
IT-VBFK force-pushed the fix/csproj-convert-version-var branch from da9ece9 to d3fc9b9 Compare July 12, 2026 11:56
@ITaluone
ITaluone force-pushed the fix/csproj-convert-version-var branch from d3fc9b9 to f3ff5e1 Compare July 12, 2026 11:57
@ITaluone

Copy link
Copy Markdown
Collaborator

@copilot review

@ITaluone
ITaluone force-pushed the fix/csproj-convert-version-var branch from f3ff5e1 to 2fb66d4 Compare July 12, 2026 13:41
@IT-VBFK IT-VBFK changed the title Recogizes version variables and updates the version accordingly Recognizes version variables and updates the version accordingly Jul 12, 2026
@IT-VBFK
IT-VBFK force-pushed the fix/csproj-convert-version-var branch from 2fb66d4 to 51c3c6b Compare July 12, 2026 18:05
@ITaluone
ITaluone force-pushed the fix/csproj-convert-version-var branch 2 times, most recently from 0550dd3 to 8e438a1 Compare July 14, 2026 06:16
Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
@ITaluone

ITaluone commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Do not merge, please (meaning now).

I rebase the commits later to better commits :)

@ITaluone
ITaluone requested a review from avidenic July 15, 2026 13:47
Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
Comment thread tests/Fallout.Migrate.Specs/CsprojRewriterSpecs.cs
@IT-VBFK
IT-VBFK force-pushed the fix/csproj-convert-version-var branch from fb768bd to 32902ef Compare July 15, 2026 15:28
@ITaluone

Copy link
Copy Markdown
Collaborator

@avidenic Can you do the final review.. mine isn't worth it (person from IT-VBFK == ITaluone) ;)

@dennisdoomen

Copy link
Copy Markdown
Collaborator

As I'm cleaning up the migration, please wait with the merge after which I've taken a look.

@avidenic avidenic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvements, some small issues to look at. Some should probably go into follow up issues / PRs. Or we can decide we're fine and just add docs about gaps.

Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
@ITaluone ITaluone added the AI code Contains AI code label Jul 16, 2026
@ITaluone
ITaluone force-pushed the fix/csproj-convert-version-var branch from 80cc687 to a3240c0 Compare July 16, 2026 14:51

@avidenic avidenic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Substantial improvements. There are still some decisions to be made though.

Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
Comment thread tests/Fallout.Migrate.Specs/CsprojRewriterSpecs.cs Outdated
Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated

@dennisdoomen dennisdoomen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to up our game here, even for our migration code, as that is going to be existing for years to come. So I'm going to be a bit more critical on the code review level. Don't get me wrong. We love all these contributions, but Nuke's code hasn't been particularly well factored and documented. So bear with me.

🔧 The PRs should explain what they are trying to do. Just a reference to an old (potentially convoluted) Nuke issue isn't enough anymore.
📝 The new code in this PR is IMO too long, too cryptic and has too little documentation.

Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
Comment thread tests/Fallout.Migrate.Specs/CsprojRewriterSpecs.cs Outdated
Comment thread docs/migration/from-nuke.md Outdated
@IT-VBFK

IT-VBFK commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

Ok.. I propose to start over with small focused steps

Ok @dennisdoomen?

@dennisdoomen

Copy link
Copy Markdown
Collaborator

Ok.. I propose to start over with small focused steps

Yeah, and base it on #507

@IT-VBFK

IT-VBFK commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

Cool
Will do so

I couldn't imagine how far your migration refactoring could go 😂😂

@IT-VBFK
IT-VBFK force-pushed the fix/csproj-convert-version-var branch 2 times, most recently from 02e6f48 to 75c7270 Compare July 19, 2026 16:40
@ITaluone
ITaluone force-pushed the fix/csproj-convert-version-var branch from 75c7270 to f29e707 Compare July 23, 2026 12:32
@ITaluone
ITaluone force-pushed the fix/csproj-convert-version-var branch from f29e707 to cb4fb9d Compare July 23, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI code Contains AI code enhancement New feature or request target/vCurrent Targets the current version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fallout.Migrate: Also recognize csproj variables

6 participants