Skip to content

Pass the build's versions to the examples MSBuild call - #352

Merged
lahma merged 1 commit into
mainfrom
fix-example-assembly-versions
Aug 9, 2026
Merged

Pass the build's versions to the examples MSBuild call#352
lahma merged 1 commit into
mainfrom
fix-example-assembly-versions

Conversation

@lahma

@lahma lahma commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Fixes the build-windows regression from #351. CompileExamples currently fails with:

error CS1705: Assembly 'Spring.Messaging' with identity 'Spring.Messaging, Version=3.1.0.0'
uses 'Spring.Core, Version=3.1.0.0' which has a higher version than referenced assembly
'Spring.Core' with identity 'Spring.Core, Version=1.0.0.0'

Cause

Four example solutions include the src/Spring projects directly rather than referencing built output:

examples/.../Spring.Northwind.sln                  <- built by CompileExamples
examples/.../Spring.Scheduling.Quartz.Example.sln  <- built by CompileExamples
examples/.../Spring.WebQuickStart.sln              <- skipped
examples/.../SpringAir.sln                         <- skipped

So MSBuild /target:Restore;Rebuild on those recompiles Spring.Core and friends straight back into build/$(Configuration)/. That call passed no version properties, so the rebuild stamped the SDK default 1.0.0.0 over what CompileSolution had produced.

While every assembly was 1.0.0.0 this was invisible — the versions were uniformly wrong, so nothing conflicted. Now that CompileSolution sets real versions it is a hard failure: build/Release/Spring.Core/net462/Spring.Core.dll gets clobbered to 1.0.0.0, while the copies already distributed into the other projects' output folders during CompileSolution are still 3.1.0.0. The CI log shows exactly this — Northwind builds first and clobbers, then MsmqQuickStart hits the conflict:

MSB3277: There was a conflict between "Spring.Core, Version=1.0.0.0" and "Spring.Core, Version=3.1.0.0".
  "Spring.Core, Version=1.0.0.0" ... [build\Release\Spring.Core\net462\Spring.Core.dll]
  "Spring.Core, Version=3.1.0.0" ... [build\Release\Spring.Messaging\net462\Spring.Core.dll]

Fix

Apply the same versions to the examples MSBuild invocation, so every path that writes into build/ agrees. MSBuildSettings has no VersionPrefix/VersionSuffix setter, so those two go through SetProperty.

Verification

CompileExamples cannot run on this machine (VS 2022's MSBuild 17.14 cannot load SDK 10.0.302 projects — CI uses VS 18), so the mechanism was reproduced directly with dotnet build on the Quartz example solution, which takes the same path:

BEFORE                          : 3.1.0.0
AFTER build WITHOUT version args: 1.0.0.0   <- reproduces the bug
AFTER build WITH version args   : 3.1.0.0   <- fixed

The emitted command line now carries them:

msbuild.exe ...Spring.AopQuickStart.sln /target:Restore;Rebuild /p:Configuration=Release
  /p:AssemblyVersion=3.1.0.0 /p:FileVersion=3.1.0 /p:VersionPrefix=3.1.0 /p:VersionSuffix=dev-20260809-0956

build-windows on this PR is the real check, since it is the only place CompileExamples actually runs.

Four example solutions include the src/Spring projects directly - Northwind
and the Quartz example are built by CompileExamples, SpringAir and
WebQuickStart are skipped - so MSBuild's Rebuild recompiles Spring.Core and
friends straight back into build/$(Configuration)/.

That call passed no version properties, so the rebuild stamped the SDK default
1.0.0.0 over what CompileSolution had produced. While every assembly was
1.0.0.0 this was invisible. Now that CompileSolution sets real versions it is
a hard failure: the clobbered Spring.Core is 1.0.0.0 while the copies already
distributed into the other projects' output folders are 3.1.0.0, and the next
example to reference two Spring assemblies dies with

  error CS1705: Assembly 'Spring.Messaging' ... uses 'Spring.Core,
  Version=3.1.0.0' which has a higher version than referenced assembly
  'Spring.Core' with identity 'Spring.Core, Version=1.0.0.0'

Apply the same versions to the MSBuild invocation. MSBuildSettings has no
VersionPrefix/VersionSuffix setter, so those two go through SetProperty.

Reproduced and verified locally with dotnet build on the Quartz example
solution, which takes the same path: building it without version arguments
takes build/Release/Spring.Core/net462/Spring.Core.dll from 3.1.0.0 to
1.0.0.0, and building it with them leaves it at 3.1.0.0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
@lahma
lahma merged commit a628ec8 into main Aug 9, 2026
3 checks passed
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.

1 participant