Allow host info passed in from the command line to override machine settings (#5904)
* Allow host info passed in from the command line to override machine settings * Simplify the logic * Address PR comments to keep a separate HostRid and HostOSName that are static * Rename to BuildInfo.props * Address PR comments * Fix the previous merge * Fix spacing * Address PR comments
This commit is contained in:
parent
22816d7958
commit
45a1e9e56c
13 changed files with 73 additions and 25 deletions
39
build/BuildInfo.targets
Normal file
39
build/BuildInfo.targets
Normal file
|
@ -0,0 +1,39 @@
|
|||
<Project ToolsVersion="15.0">
|
||||
<Target Name="WriteBuildInfoProps"
|
||||
DependsOnTargets="BuildDotnetCliBuildFramework">
|
||||
|
||||
<GetCurrentRuntimeInformation>
|
||||
<Output TaskParameter="Rid" PropertyName="HostRid" />
|
||||
<Output TaskParameter="OSName" PropertyName="HostOSName" />
|
||||
</GetCurrentRuntimeInformation>
|
||||
|
||||
<PropertyGroup>
|
||||
<Rid Condition=" '$(Rid)' == '' ">$(HostRid)</Rid>
|
||||
<Architecture Condition=" '$(Architecture)' == '' ">x64</Architecture>
|
||||
<OSName Condition=" '$(OSName)' == '' ">$(HostOSName)</OSName>
|
||||
|
||||
<BuildInfoPropsContent>
|
||||
<Project ToolsVersion="15.0">
|
||||
<PropertyGroup>
|
||||
<Rid>$(Rid)</Rid>
|
||||
<Architecture>$(Architecture)</Architecture>
|
||||
<OSName>$(OSName)</OSName>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</BuildInfoPropsContent>
|
||||
|
||||
<ExistingBuildInfoPropsContent Condition=" Exists('$(BuildInfoProps)') ">
|
||||
$([System.IO.File]::ReadAllText($(BuildInfoProps)))
|
||||
</ExistingBuildInfoPropsContent>
|
||||
|
||||
<ShouldOverwriteBuildInfoPropsFile>false</ShouldOverwriteBuildInfoPropsFile>
|
||||
<ShouldOverwriteBuildInfoPropsFile
|
||||
Condition=" '$(ExistingBuildInfoPropsContent.Trim())' != '$(BuildInfoPropsContent.Trim())' ">true</ShouldOverwriteBuildInfoPropsFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<WriteLinesToFile File="$(BuildInfoProps)"
|
||||
Lines="$(BuildInfoPropsContent)"
|
||||
Condition=" '$(ShouldOverwriteBuildInfoPropsFile)' == 'true' "
|
||||
Overwrite="true" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -22,10 +22,6 @@
|
|||
|
||||
<GitInfoCommitHash>%(GitInfoCommitHashLines.Identity)</GitInfoCommitHash>
|
||||
|
||||
<ShouldOverWriteThePropsFile
|
||||
Condition=" 'ForceStringComparison$(CommitCount)' != 'ForceStringComparison$(GitInfoCommitCount)' Or
|
||||
'$(CommitHash)' != '$(GitInfoCommitHash)' ">true</ShouldOverWriteThePropsFile>
|
||||
|
||||
<GitCommitInfoPropsContent>
|
||||
<Project ToolsVersion="15.0">
|
||||
<PropertyGroup>
|
||||
|
@ -34,12 +30,19 @@
|
|||
</PropertyGroup>
|
||||
</Project>
|
||||
</GitCommitInfoPropsContent>
|
||||
|
||||
<ExistingGitCommitInfoProps Condition=" Exists('$(GitCommitInfoProps)') ">
|
||||
$([System.IO.File]::ReadAllText($(GitCommitInfoProps)))
|
||||
</ExistingGitCommitInfoProps>
|
||||
|
||||
<ShouldOverwriteGitCommitInfoPropsFile>false</ShouldOverwriteGitCommitInfoPropsFile>
|
||||
<ShouldOverwriteGitCommitInfoPropsFile
|
||||
Condition=" '$(ExistingGitCommitInfoProps.Trim())' != '$(GitCommitInfoPropsContent.Trim())' ">true</ShouldOverwriteGitCommitInfoPropsFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<WriteLinesToFile File="$(GitCommitInfoProps)"
|
||||
Lines="$(GitCommitInfoPropsContent)"
|
||||
Condition=" '$(ShouldOverwriteThePropsFile)' == 'true' "
|
||||
Condition=" '$(ShouldOverwriteGitCommitInfoPropsFile)' == 'true' "
|
||||
Overwrite="true" />
|
||||
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
<Target Name="WriteHostInfoProps"
|
||||
Condition=" !Exists('$(HostInfoProps)') "
|
||||
DependsOnTargets="BuildDotnetCliBuildFramework">
|
||||
<!-- Current Runtime Information -->
|
||||
|
||||
<GetCurrentRuntimeInformation>
|
||||
<Output TaskParameter="Rid" PropertyName="HostRid" />
|
||||
<Output TaskParameter="Architecture" PropertyName="HostArchitecture" />
|
||||
<Output TaskParameter="OSName" PropertyName="HostOSName" />
|
||||
</GetCurrentRuntimeInformation>
|
||||
|
||||
|
@ -13,9 +12,8 @@
|
|||
<HostInfoPropsContent>
|
||||
<Project ToolsVersion="15.0">
|
||||
<PropertyGroup>
|
||||
<Rid>$(HostRid)</Rid>
|
||||
<Architecture>$(HostArchitecture)</Architecture>
|
||||
<OSName>$(HostOSName)</OSName>
|
||||
<HostRid>$(HostRid)</HostRid>
|
||||
<HostOSName>$(HostOSName)</HostOSName>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</HostInfoPropsContent>
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
<GeneratedPropsDir>$(RepoRoot)/artifacts/obj</GeneratedPropsDir>
|
||||
<GitCommitInfoProps>$(GeneratedPropsDir)/GitCommitInfo.props</GitCommitInfoProps>
|
||||
<HostInfoProps>$(GeneratedPropsDir)/HostInfo.props</HostInfoProps>
|
||||
<BuildInfoProps>$(GeneratedPropsDir)/BuildInfo.props</BuildInfoProps>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
DependsOnTargets="BuildDotnetCliBuildFramework;
|
||||
EnsureGeneratedPropsDirectory;
|
||||
WriteGitCommitInfoProps;
|
||||
WriteHostInfoProps"/>
|
||||
WriteHostInfoProps;
|
||||
WriteBuildInfoProps"/>
|
||||
|
||||
<Target Name="EnsureGeneratedPropsDirectory">
|
||||
<MakeDir Condition=" !Exists('$(GeneratedPropsDir)') "
|
||||
|
|
|
@ -7,11 +7,19 @@
|
|||
DependsOnTargets="Init;DownloadHostAndSharedFxArtifacts;RestoreSrcPackages;RestoreToolsPackages" />
|
||||
|
||||
<Target Name="Init"
|
||||
DependsOnTargets="SetTelemetryProfile;
|
||||
DependsOnTargets="PrintBuildInfo;
|
||||
SetTelemetryProfile;
|
||||
BuildDotnetCliBuildFramework;
|
||||
CheckPrereqs;">
|
||||
</Target>
|
||||
|
||||
<Target Name="PrintBuildInfo">
|
||||
<Message Text="Host info - Rid: $(HostRid), OSName: $(HostOSName)" Importance="High" />
|
||||
<Message Text="Build info - Rid: $(Rid), Architecture: $(Architecture), OSName: $(OSName)" Importance="High" />
|
||||
<Message Text="If you intended to use a different Rid, Architecture, or OSName run the following command to generate your build state:" Importance="High" />
|
||||
<Message Text="dotnet msbuild build.proj /p:Architecture=Architecture /p:Rid=Rid /p:OSName=OSName /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles" Importance="High" />
|
||||
</Target>
|
||||
|
||||
<Target Name="SetTelemetryProfile"
|
||||
DependsOnTargets="BuildDotnetCliBuildFramework" >
|
||||
<SetEnvVar Name="DOTNET_CLI_TELEMETRY_PROFILE" Value="$(DOTNET_CLI_TELEMETRY_PROFILE);https://github.com/dotnet/cli;$(CommitHash)" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue