Skip to content

Recognizes version variables and updates the version accordingly - #478

Open
IT-VBFK wants to merge 2 commits 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 2 commits 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 Outdated
Comment thread src/Fallout.Migrate/CsprojRewriter.cs Outdated
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 Outdated
@IT-VBFK
IT-VBFK force-pushed the fix/csproj-convert-version-var branch from fb768bd to 32902ef Compare July 15, 2026 15:28
@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 2 times, most recently from f29e707 to cb4fb9d Compare July 23, 2026 12:46

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

Nice improvement with a little bit of rework

Comment thread src/Fallout.Migrate/Steps/RewriteCsprojsStep.cs
Comment thread src/Fallout.Migrate/Steps/RewriteCsprojsStep.cs Outdated
Comment thread src/Fallout.Migrate/Steps/RewriteCsprojsStep.cs Outdated
Comment thread src/Fallout.Migrate/Steps/RewriteCsprojsStep.cs Outdated
Comment thread src/Fallout.Migrate/Steps/RewriteCsprojsStep.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.

Grouped review: three related findings on the new property-variable bump logic.

Comment thread src/Fallout.Migrate/Steps/RewriteCsprojsStep.cs
Comment thread src/Fallout.Migrate/Steps/RewriteCsprojsStep.cs Outdated
Comment thread tests/Fallout.Migrate.Specs/RewriteCsprojsStepSpecs.cs
@IT-VBFK
IT-VBFK force-pushed the fix/csproj-convert-version-var branch 2 times, most recently from c779f2c to 39b1b12 Compare July 25, 2026 11:30
@IT-VBFK

IT-VBFK commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

Ok.. as I can see this is more or less the version like before, except the verify conversion

@IT-VBFK
IT-VBFK requested a review from dennisdoomen July 25, 2026 11:31
Comment thread src/Fallout.Migrate/Steps/RewriteCsprojsStep.cs
@IT-VBFK
IT-VBFK force-pushed the fix/csproj-convert-version-var branch 3 times, most recently from a3f2075 to 8da8ebc Compare July 27, 2026 19:12
@ITaluone

Copy link
Copy Markdown
Collaborator

Can we move forward on that one?

And: can this go into 10.4?

@dennisdoomen

Copy link
Copy Markdown
Collaborator

Can we move forward on that one?

You've marked some of my (and my AI friend's) comments as resolved, but didn't answer nor fix anything. I've reopened those.

@ITaluone
ITaluone force-pushed the fix/csproj-convert-version-var branch from 8da8ebc to e93de33 Compare July 29, 2026 08:06
@ITaluone

Copy link
Copy Markdown
Collaborator

Can we move forward on that one?

You've marked some of my (and my AI friend's) comments as resolved, but didn't answer nor fix anything. I've reopened those.

Sorry that this went like that..

Added a new test case for the non-PropertyGroup case, and added whitespaces to the version property tags.

@ITaluone
ITaluone force-pushed the fix/csproj-convert-version-var branch from e93de33 to 5b26331 Compare July 29, 2026 08:17
@ITaluone
ITaluone force-pushed the fix/csproj-convert-version-var branch from 5b26331 to 943586a Compare July 29, 2026 08:19
@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

im a bit lost with this one @IT-VBFK is this ready for review now? if we wanna get this in into 10.4 I'd say lets try to get this merged in the next few days :-)

@IT-VBFK

IT-VBFK commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Yes
Ready for review

@ITaluone ITaluone added this to the v10.4 milestone Jul 30, 2026
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