Skip to content

chore: derive every version from a single <Version> - #461

Merged
lduchosal merged 1 commit into
masterfrom
chore/single-source-version
Oct 24, 2026
Merged

lduchosal merged 1 commit into
masterfrom
chore/single-source-version

Conversation

@lduchosal

Copy link
Copy Markdown
Owner

Summary

The version used to be written in five places that nothing kept in sync, and AssemblyVersion had been left at 3.2.0.0 for several 4.x releases. Worse, because the library used GenerateAssemblyInfo=false, the /p:Version=<tag> that release.yml passes never reached AssemblyVersion and AssemblyFileVersion: the published DLL carried whatever was hard-coded in AssemblyInfo.cs.

The version is now defined once, and everything else derives from it.

Where Before After
src/Directory.Build.props — <Version>5.0.1</Version>, the single source
System.Net.IPNetwork.csproj PackageVersion derived from Version
Properties/AssemblyInfo.cs hard-coded AssemblyVersion / AssemblyFileVersion generated by the SDK
TestProject.csproj, ConsoleApplication.csproj own Version inherited
appveyor.yml patched every AssemblyInfo and .csproj with {version} no patching; its version only labels the build

How the versions derive

For Version = 5.0.1, or the release tag passed with /p:Version:

Library (strong-named) Console app
Package version 5.0.1 —
AssemblyVersion 5.0.0.0 (major only: minor and patch releases don't force a recompile) 5.0.1.0 (shown by --version)
AssemblyFileVersion 5.0.1.0 5.0.1.0
AssemblyInformationalVersion 5.0.1+<commit> 5.0.1+<commit>

The library keeps its descriptive attributes (title, company, copyright, ...) in AssemblyInfo.cs. Only the version attributes are generated now, and the matching generators are turned off to avoid duplicates.

Guard

VersionConsistencyUnitTest compares the version recorded in the test assembly at build time (AssemblyMetadata ExpectedVersion = $(Version)) with what the library and the console DLLs actually carry. Any future drift fails CI.

versionize

Checked on a scratch repository: versionize discovers and bumps a <Version> in Directory.Build.props ("Discovered 1 versionable projects … Directory.Build.props, bumping version from 5.0.1 to 5.0.2").

Tests

  • 1408/1408 pass on net10.0, including the 2 new version tests.
  • Simulated release with /p:Version=5.2.3-beta.1: the version tests pass, and dotnet pack produces IPNetwork2.5.2.3-beta.1.nupkg.

🤖 Generated with Claude Code

Define the version once in src/Directory.Build.props. The library now
generates AssemblyVersion (major only, as it is strong-named),
AssemblyFileVersion and AssemblyInformationalVersion from it instead of
hard-coding them in AssemblyInfo.cs, which the /p:Version of a release
never reached. The per-project versions go, AppVeyor no longer patches
version numbers into the files, and a test checks that every assembly
carries the solution version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mergify

mergify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@coveralls

coveralls commented Oct 24, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 1053

Coverage remained the same at 94.172%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 2471
Covered Lines: 2327
Line Coverage: 94.17%
Coverage Strength: 630015.36 hits per line

💛 - Coveralls

@sonarqubecloud

Copy link
Copy Markdown

@lduchosal
lduchosal merged commit a90c0d0 into master Oct 24, 2026
14 of 16 checks passed
@lduchosal
lduchosal deleted the chore/single-source-version branch October 24, 2026 16:01

This branch had an error being deployed

1 failed deployment
github-pages — 20b37b18 Deployed Oct 24, 2026 by lduchosal via Generate and publish the docs #268
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.

2 participants