From 38966b4a7c27ac2eca247d20ee85de87ac41b284 Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Fri, 22 Mar 2024 11:43:18 -0500 Subject: [PATCH 1/2] Generate a props file that can be used to detect MSBuild version mismatches. We know the minimum and 'bundled' MSbuild versions, but users may build a project with newer SDKs than we expected (specifically when full-framework MSBuild is starting the build of an SDK-style project). When this occurs, we'd like to automatically condition the use of PackageReferences meant to ensure compatibility of the Roslyn toolchain, so we need to know if we are in this mismatched situation. A fast and simple way to do this is to 'stamp' the 'expected' version of MSBuild during product construction and compare that to the 'current' version being used during the actual build. --- .../targets/GenerateBundledVersions.targets | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/redist/targets/GenerateBundledVersions.targets b/src/redist/targets/GenerateBundledVersions.targets index a678fce04..bb8574797 100644 --- a/src/redist/targets/GenerateBundledVersions.targets +++ b/src/redist/targets/GenerateBundledVersions.targets @@ -2,7 +2,7 @@ + DependsOnTargets="GenerateBundledVersionsProps;GenerateBundledCliToolsProps;GenerateBundledMSBuildProps" > + + + Microsoft.NETCoreSdk.BundledMSBuildInformation.props + %(SDKInternalFiles.Identity) + $(MSBuildVersion) + + + + + + + + <_BundledMSBuildVersionMajorMinor>$([System.Version]::Parse('$(BundledMSBuildVersion)').ToString(2)) + + + + + + + + $(MinimumMSBuildVersion) + $(BundledMSBuildVersion) + <_MSBuildVersionMajorMinor>%24([System.Version]::Parse('%24(MSBuildVersion)').ToString(2)) + <_IsDisjointMSBuildVersion>%24([MSBuild]::VersionGreaterThan('%24(_MSBuildVersionMajorMinor)', '$(_BundledMSBuildVersionMajorMinor)')) + + +]]> + + + + + + From ac487ddeb1fbb7ac2f26bf373f79692c0f3fa294 Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Fri, 22 Mar 2024 13:22:46 -0500 Subject: [PATCH 2/2] Fix reading of minimum MSBuild version --- src/redist/targets/GenerateBundledVersions.targets | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/redist/targets/GenerateBundledVersions.targets b/src/redist/targets/GenerateBundledVersions.targets index bb8574797..71ad70903 100644 --- a/src/redist/targets/GenerateBundledVersions.targets +++ b/src/redist/targets/GenerateBundledVersions.targets @@ -1248,11 +1248,13 @@ Copyright (c) .NET Foundation. All rights reserved. + $(RedistLayoutPath)sdk/$(Version)/minimumMSBuildVersion Microsoft.NETCoreSdk.BundledMSBuildInformation.props - %(SDKInternalFiles.Identity) $(MSBuildVersion) + +