Generate a props file that can be used to detect MSBuild version mismatches (#19144)

This commit is contained in:
Chet Husk 2024-03-23 11:07:07 -05:00 committed by GitHub
commit 420a491027
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,7 +2,7 @@
<Target Name="GenerateBundledVersions"
Condition="'$(PgoInstrument)' != 'true'"
DependsOnTargets="GenerateBundledVersionsProps;GenerateBundledCliToolsProps" >
DependsOnTargets="GenerateBundledVersionsProps;GenerateBundledCliToolsProps;GenerateBundledMSBuildProps" >
<WriteLinesToFile
File="$(ArtifactsShippingPackagesDir)productVersion.txt"
@ -1246,6 +1246,54 @@ Copyright (c) .NET Foundation. All rights reserved.
Overwrite="true" />
</Target>
<Target Name="GenerateBundledMSBuildProps" DependsOnTargets="SetupBundledComponents">
<PropertyGroup>
<MinimumMSBuildVersionFile>$(RedistLayoutPath)sdk/$(Version)/minimumMSBuildVersion</MinimumMSBuildVersionFile>
<BundledMSBuildPropsFileName>Microsoft.NETCoreSdk.BundledMSBuildInformation.props</BundledMSBuildPropsFileName>
<BundledMSBuildVersion>$(MSBuildVersion)</BundledMSBuildVersion>
</PropertyGroup>
<Error Text="No MSBuild version file found under '$(RedistLayoutPath)sdk/$(Version)'" Condition="!Exists('$(MinimumMSBuildVersionFile)')" />
<ReadLinesFromFile File="$(MinimumMSBuildVersionFile)">
<Output TaskParameter="Lines" PropertyName="MinimumMSBuildVersion"/>
</ReadLinesFromFile>
<PropertyGroup>
<_BundledMSBuildVersionMajorMinor>$([System.Version]::Parse('$(BundledMSBuildVersion)').ToString(2))</_BundledMSBuildVersionMajorMinor>
</PropertyGroup>
<PropertyGroup>
<BundledMSBuildPropsFileContent>
<![CDATA[
<!--
***********************************************************************************************
$(BundledMSBuildPropsFileName)
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project>
<PropertyGroup>
<MinimumMSBuildVersion>$(MinimumMSBuildVersion)</MinimumMSBuildVersion>
<BundledMSBuildVersion>$(BundledMSBuildVersion)</BundledMSBuildVersion>
<_MSBuildVersionMajorMinor>%24([System.Version]::Parse('%24(MSBuildVersion)').ToString(2))</_MSBuildVersionMajorMinor>
<_IsDisjointMSBuildVersion>%24([MSBuild]::VersionGreaterThan('%24(_MSBuildVersionMajorMinor)', '$(_BundledMSBuildVersionMajorMinor)'))</_IsDisjointMSBuildVersion>
</PropertyGroup>
</Project>
]]>
</BundledMSBuildPropsFileContent>
</PropertyGroup>
<WriteLinesToFile File="$(SdkOutputDirectory)$(BundledMSBuildPropsFileName)"
Lines="$(BundledMSBuildPropsFileContent)"
Overwrite="true" />
</Target>
<ItemGroup>
<PackageDownload Include="Microsoft.NETCore.Platforms" Version="[$(MicrosoftNETCorePlatformsPackageVersion)]" />
</ItemGroup>