From dec08df6d1f76ee3b37117db76d3364994c1aec4 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sun, 9 Aug 2026 12:57:55 +0300 Subject: [PATCH] Pass the build's versions to the examples MSBuild call 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) Signed-off-by: Marko Lahma --- build-support/build/Build.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/build-support/build/Build.cs b/build-support/build/Build.cs index b6832c55c..9e1dbfb58 100644 --- a/build-support/build/Build.cs +++ b/build-support/build/Build.cs @@ -155,6 +155,7 @@ void DetermineVersion() MSBuild(s => s .SetTargets("Restore", "Rebuild") .SetConfiguration(Configuration) + .Apply(ExampleVersionSettings) .SetTargetPath(solutionFile) .SetNodeReuse(false) .SetVerbosity(MSBuildVerbosity.Minimal) @@ -230,6 +231,17 @@ void DetermineVersion() .SetVersionPrefix(VersionPrefix) .SetVersionSuffix(VersionSuffix); + // Several example solutions include the src/Spring projects directly (Spring.Core.csproj and + // friends), so this MSBuild call rebuilds them straight back into build/$(Configuration)/. + // Without the same versions, that rebuild stamps the SDK default 1.0.0.0 over what + // CompileSolution produced, and the next example to reference two Spring assemblies fails + // CS1705 on the mismatch. MSBuildSettings has no VersionPrefix/Suffix setter, hence SetProperty. + Configure ExampleVersionSettings => _ => _ + .SetAssemblyVersion(AssemblyVersion) + .SetFileVersion(VersionPrefix) + .SetProperty("VersionPrefix", VersionPrefix) + .SetProperty("VersionSuffix", VersionSuffix ?? string.Empty); + IEnumerable GetActiveProjects() { var packTargets = Solution.AllProjects