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
|
@ -20,7 +20,7 @@
|
||||||
DependsOnTargets="MSBuildWorkaroundTarget;
|
DependsOnTargets="MSBuildWorkaroundTarget;
|
||||||
RestoreDotnetCliBuildFramework">
|
RestoreDotnetCliBuildFramework">
|
||||||
|
|
||||||
<Exec Command="$(DotnetStage0) publish -o $(DotnetCliBuildDirectory)/bin --framework netcoreapp1.0 /p:GeneratingPropsFile=true"
|
<Exec Command="$(DotnetStage0) publish -o $(DotnetCliBuildDirectory)/bin --framework netcoreapp1.0 /p:GeneratePropsFile=$(GeneratePropsFile)"
|
||||||
WorkingDirectory="$(DotnetCliBuildDirectory)"/>
|
WorkingDirectory="$(DotnetCliBuildDirectory)"/>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
Outputs="@(RestoreDotnetCliBuildFrameworkOutputs)">
|
Outputs="@(RestoreDotnetCliBuildFrameworkOutputs)">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ExtraRestoreArgs Condition=" '$(GeneratingPropsFile)' == 'true' ">$(ExtraRestoreArgs) /p:GeneratingPropsFile=$(GeneratingPropsFile)</ExtraRestoreArgs>
|
<ExtraRestoreArgs>$(ExtraRestoreArgs) /p:GeneratePropsFile=$(GeneratePropsFile)</ExtraRestoreArgs>
|
||||||
<ExtraRestoreArgs Condition="'$(OS)' != 'Windows_NT'">$(ExtraRestoreArgs) --disable-parallel</ExtraRestoreArgs>
|
<ExtraRestoreArgs Condition="'$(OS)' != 'Windows_NT'">$(ExtraRestoreArgs) --disable-parallel</ExtraRestoreArgs>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@
|
||||||
|
|
||||||
<Import Project="build/GitCommitInfo.targets" />
|
<Import Project="build/GitCommitInfo.targets" />
|
||||||
<Import Project="build/HostInfo.targets" />
|
<Import Project="build/HostInfo.targets" />
|
||||||
|
<Import Project="build/BuildInfo.targets" />
|
||||||
<Import Project="build/Prepare.targets" />
|
<Import Project="build/Prepare.targets" />
|
||||||
<Import Project="build/Compile.targets" />
|
<Import Project="build/Compile.targets" />
|
||||||
<Import Project="build/Package.targets" />
|
<Import Project="build/Package.targets" />
|
||||||
|
|
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>
|
<GitInfoCommitHash>%(GitInfoCommitHashLines.Identity)</GitInfoCommitHash>
|
||||||
|
|
||||||
<ShouldOverWriteThePropsFile
|
|
||||||
Condition=" 'ForceStringComparison$(CommitCount)' != 'ForceStringComparison$(GitInfoCommitCount)' Or
|
|
||||||
'$(CommitHash)' != '$(GitInfoCommitHash)' ">true</ShouldOverWriteThePropsFile>
|
|
||||||
|
|
||||||
<GitCommitInfoPropsContent>
|
<GitCommitInfoPropsContent>
|
||||||
<Project ToolsVersion="15.0">
|
<Project ToolsVersion="15.0">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
@ -34,12 +30,19 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
</GitCommitInfoPropsContent>
|
</GitCommitInfoPropsContent>
|
||||||
|
|
||||||
|
<ExistingGitCommitInfoProps Condition=" Exists('$(GitCommitInfoProps)') ">
|
||||||
|
$([System.IO.File]::ReadAllText($(GitCommitInfoProps)))
|
||||||
|
</ExistingGitCommitInfoProps>
|
||||||
|
|
||||||
|
<ShouldOverwriteGitCommitInfoPropsFile>false</ShouldOverwriteGitCommitInfoPropsFile>
|
||||||
|
<ShouldOverwriteGitCommitInfoPropsFile
|
||||||
|
Condition=" '$(ExistingGitCommitInfoProps.Trim())' != '$(GitCommitInfoPropsContent.Trim())' ">true</ShouldOverwriteGitCommitInfoPropsFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<WriteLinesToFile File="$(GitCommitInfoProps)"
|
<WriteLinesToFile File="$(GitCommitInfoProps)"
|
||||||
Lines="$(GitCommitInfoPropsContent)"
|
Lines="$(GitCommitInfoPropsContent)"
|
||||||
Condition=" '$(ShouldOverwriteThePropsFile)' == 'true' "
|
Condition=" '$(ShouldOverwriteGitCommitInfoPropsFile)' == 'true' "
|
||||||
Overwrite="true" />
|
Overwrite="true" />
|
||||||
|
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
<Target Name="WriteHostInfoProps"
|
<Target Name="WriteHostInfoProps"
|
||||||
Condition=" !Exists('$(HostInfoProps)') "
|
Condition=" !Exists('$(HostInfoProps)') "
|
||||||
DependsOnTargets="BuildDotnetCliBuildFramework">
|
DependsOnTargets="BuildDotnetCliBuildFramework">
|
||||||
<!-- Current Runtime Information -->
|
|
||||||
<GetCurrentRuntimeInformation>
|
<GetCurrentRuntimeInformation>
|
||||||
<Output TaskParameter="Rid" PropertyName="HostRid" />
|
<Output TaskParameter="Rid" PropertyName="HostRid" />
|
||||||
<Output TaskParameter="Architecture" PropertyName="HostArchitecture" />
|
|
||||||
<Output TaskParameter="OSName" PropertyName="HostOSName" />
|
<Output TaskParameter="OSName" PropertyName="HostOSName" />
|
||||||
</GetCurrentRuntimeInformation>
|
</GetCurrentRuntimeInformation>
|
||||||
|
|
||||||
|
@ -13,9 +12,8 @@
|
||||||
<HostInfoPropsContent>
|
<HostInfoPropsContent>
|
||||||
<Project ToolsVersion="15.0">
|
<Project ToolsVersion="15.0">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Rid>$(HostRid)</Rid>
|
<HostRid>$(HostRid)</HostRid>
|
||||||
<Architecture>$(HostArchitecture)</Architecture>
|
<HostOSName>$(HostOSName)</HostOSName>
|
||||||
<OSName>$(HostOSName)</OSName>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
</HostInfoPropsContent>
|
</HostInfoPropsContent>
|
||||||
|
|
|
@ -3,5 +3,6 @@
|
||||||
<GeneratedPropsDir>$(RepoRoot)/artifacts/obj</GeneratedPropsDir>
|
<GeneratedPropsDir>$(RepoRoot)/artifacts/obj</GeneratedPropsDir>
|
||||||
<GitCommitInfoProps>$(GeneratedPropsDir)/GitCommitInfo.props</GitCommitInfoProps>
|
<GitCommitInfoProps>$(GeneratedPropsDir)/GitCommitInfo.props</GitCommitInfoProps>
|
||||||
<HostInfoProps>$(GeneratedPropsDir)/HostInfo.props</HostInfoProps>
|
<HostInfoProps>$(GeneratedPropsDir)/HostInfo.props</HostInfoProps>
|
||||||
|
<BuildInfoProps>$(GeneratedPropsDir)/BuildInfo.props</BuildInfoProps>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
DependsOnTargets="BuildDotnetCliBuildFramework;
|
DependsOnTargets="BuildDotnetCliBuildFramework;
|
||||||
EnsureGeneratedPropsDirectory;
|
EnsureGeneratedPropsDirectory;
|
||||||
WriteGitCommitInfoProps;
|
WriteGitCommitInfoProps;
|
||||||
WriteHostInfoProps"/>
|
WriteHostInfoProps;
|
||||||
|
WriteBuildInfoProps"/>
|
||||||
|
|
||||||
<Target Name="EnsureGeneratedPropsDirectory">
|
<Target Name="EnsureGeneratedPropsDirectory">
|
||||||
<MakeDir Condition=" !Exists('$(GeneratedPropsDir)') "
|
<MakeDir Condition=" !Exists('$(GeneratedPropsDir)') "
|
||||||
|
|
|
@ -7,11 +7,19 @@
|
||||||
DependsOnTargets="Init;DownloadHostAndSharedFxArtifacts;RestoreSrcPackages;RestoreToolsPackages" />
|
DependsOnTargets="Init;DownloadHostAndSharedFxArtifacts;RestoreSrcPackages;RestoreToolsPackages" />
|
||||||
|
|
||||||
<Target Name="Init"
|
<Target Name="Init"
|
||||||
DependsOnTargets="SetTelemetryProfile;
|
DependsOnTargets="PrintBuildInfo;
|
||||||
|
SetTelemetryProfile;
|
||||||
BuildDotnetCliBuildFramework;
|
BuildDotnetCliBuildFramework;
|
||||||
CheckPrereqs;">
|
CheckPrereqs;">
|
||||||
</Target>
|
</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"
|
<Target Name="SetTelemetryProfile"
|
||||||
DependsOnTargets="BuildDotnetCliBuildFramework" >
|
DependsOnTargets="BuildDotnetCliBuildFramework" >
|
||||||
<SetEnvVar Name="DOTNET_CLI_TELEMETRY_PROFILE" Value="$(DOTNET_CLI_TELEMETRY_PROFILE);https://github.com/dotnet/cli;$(CommitHash)" />
|
<SetEnvVar Name="DOTNET_CLI_TELEMETRY_PROFILE" Value="$(DOTNET_CLI_TELEMETRY_PROFILE);https://github.com/dotnet/cli;$(CommitHash)" />
|
||||||
|
|
|
@ -13,16 +13,12 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
[Output]
|
[Output]
|
||||||
public string Rid { get; set; }
|
public string Rid { get; set; }
|
||||||
|
|
||||||
[Output]
|
|
||||||
public string Architecture { get; set; }
|
|
||||||
|
|
||||||
[Output]
|
[Output]
|
||||||
public string OSName { get; set; }
|
public string OSName { get; set; }
|
||||||
|
|
||||||
public override bool Execute()
|
public override bool Execute()
|
||||||
{
|
{
|
||||||
Rid = RuntimeEnvironment.GetRuntimeIdentifier();
|
Rid = RuntimeEnvironment.GetRuntimeIdentifier();
|
||||||
Architecture = RuntimeEnvironment.RuntimeArchitecture;
|
|
||||||
OSName = GetOSShortName();
|
OSName = GetOSShortName();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -44,7 +44,7 @@ $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
|
||||||
|
|
||||||
# Generate some props files that are imported by update-dependencies
|
# Generate some props files that are imported by update-dependencies
|
||||||
Write-Host "Generating property files..."
|
Write-Host "Generating property files..."
|
||||||
dotnet msbuild $RepoRoot\build.proj /p:Architecture=$Architecture /p:GeneratingPropsFile=true /t:WriteDynamicPropsToStaticPropsFiles
|
dotnet msbuild $RepoRoot\build.proj /p:Architecture=$Architecture /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles
|
||||||
if($LASTEXITCODE -ne 0) { throw "Failed to generate intermidates" }
|
if($LASTEXITCODE -ne 0) { throw "Failed to generate intermidates" }
|
||||||
|
|
||||||
# Restore the app
|
# Restore the app
|
||||||
|
|
|
@ -44,7 +44,7 @@ export PATH=$DOTNET_INSTALL_DIR:$PATH
|
||||||
|
|
||||||
# Generate some props files that are imported by update-dependencies
|
# Generate some props files that are imported by update-dependencies
|
||||||
echo "Generating property files..."
|
echo "Generating property files..."
|
||||||
dotnet msbuild "$REPO_ROOT/build.proj" /p:Architecture=x64 /p:GeneratingPropsFile=true /t:WriteDynamicPropsToStaticPropsFiles
|
dotnet msbuild "$REPO_ROOT/build.proj" /p:Architecture=x64 /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles
|
||||||
|
|
||||||
echo "Resotring $PROJECT_PATH..."
|
echo "Resotring $PROJECT_PATH..."
|
||||||
dotnet restore "$PROJECT_PATH"
|
dotnet restore "$PROJECT_PATH"
|
||||||
|
|
|
@ -14,8 +14,9 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="build/InitRepo.props" />
|
<Import Project="build/InitRepo.props" />
|
||||||
<Import Condition=" Exists('$(GitCommitInfoProps)') Or '$(GeneratingPropsFile)' != 'true' " Project="$(GitCommitInfoProps)" />
|
<Import Condition=" '$(GeneratePropsFile)' != 'true' " Project="$(GitCommitInfoProps)" />
|
||||||
<Import Condition=" Exists('$(HostInfoProps)') Or '$(GeneratingPropsFile)' != 'true' " Project="$(HostInfoProps)" />
|
<Import Condition=" '$(GeneratePropsFile)' != 'true' " Project="$(HostInfoProps)" />
|
||||||
|
<Import Condition=" '$(GeneratePropsFile)' != 'true' " Project="$(BuildInfoProps)" />
|
||||||
|
|
||||||
<Import Project="build/BranchInfo.props" />
|
<Import Project="build/BranchInfo.props" />
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ if ($NoBuild)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dotnet msbuild build.proj /p:Architecture=$Architecture /p:GeneratingPropsFile=true /t:WriteDynamicPropsToStaticPropsFiles
|
dotnet msbuild build.proj /p:Architecture=$Architecture /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles
|
||||||
dotnet msbuild build.proj /m /v:diag /fl /flp:v=diag /p:Architecture=$Architecture $ExtraParameters
|
dotnet msbuild build.proj /m /v:diag /fl /flp:v=diag /p:Architecture=$Architecture $ExtraParameters
|
||||||
if($LASTEXITCODE -ne 0) { throw "Failed to build" }
|
if($LASTEXITCODE -ne 0) { throw "Failed to build" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||||
echo "${args[@]}"
|
echo "${args[@]}"
|
||||||
|
|
||||||
if [ $BUILD -eq 1 ]; then
|
if [ $BUILD -eq 1 ]; then
|
||||||
dotnet msbuild build.proj /p:Architecture=$ARCHITECTURE /p:GeneratingPropsFile=true /t:WriteDynamicPropsToStaticPropsFiles
|
dotnet msbuild build.proj /p:Architecture=$ARCHITECTURE /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles
|
||||||
dotnet msbuild build.proj /m /v:diag /fl /flp:v=diag /p:Architecture=$ARCHITECTURE "${args[@]}"
|
dotnet msbuild build.proj /m /v:diag /fl /flp:v=diag /p:Architecture=$ARCHITECTURE "${args[@]}"
|
||||||
else
|
else
|
||||||
echo "Not building due to --nobuild"
|
echo "Not building due to --nobuild"
|
||||||
|
|
Loading…
Reference in a new issue