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;
|
||||
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)"/>
|
||||
</Target>
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
|||
Outputs="@(RestoreDotnetCliBuildFrameworkOutputs)">
|
||||
|
||||
<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>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
|||
|
||||
<Import Project="build/GitCommitInfo.targets" />
|
||||
<Import Project="build/HostInfo.targets" />
|
||||
<Import Project="build/BuildInfo.targets" />
|
||||
<Import Project="build/Prepare.targets" />
|
||||
<Import Project="build/Compile.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>
|
||||
|
||||
<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)" />
|
||||
|
|
|
@ -13,16 +13,12 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[Output]
|
||||
public string Rid { get; set; }
|
||||
|
||||
[Output]
|
||||
public string Architecture { get; set; }
|
||||
|
||||
[Output]
|
||||
public string OSName { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
Rid = RuntimeEnvironment.GetRuntimeIdentifier();
|
||||
Architecture = RuntimeEnvironment.RuntimeArchitecture;
|
||||
OSName = GetOSShortName();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -44,7 +44,7 @@ $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
|
|||
|
||||
# Generate some props files that are imported by update-dependencies
|
||||
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" }
|
||||
|
||||
# Restore the app
|
||||
|
|
|
@ -44,7 +44,7 @@ export PATH=$DOTNET_INSTALL_DIR:$PATH
|
|||
|
||||
# Generate some props files that are imported by update-dependencies
|
||||
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..."
|
||||
dotnet restore "$PROJECT_PATH"
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<Import Project="build/InitRepo.props" />
|
||||
<Import Condition=" Exists('$(GitCommitInfoProps)') Or '$(GeneratingPropsFile)' != 'true' " Project="$(GitCommitInfoProps)" />
|
||||
<Import Condition=" Exists('$(HostInfoProps)') Or '$(GeneratingPropsFile)' != 'true' " Project="$(HostInfoProps)" />
|
||||
<Import Condition=" '$(GeneratePropsFile)' != 'true' " Project="$(GitCommitInfoProps)" />
|
||||
<Import Condition=" '$(GeneratePropsFile)' != 'true' " Project="$(HostInfoProps)" />
|
||||
<Import Condition=" '$(GeneratePropsFile)' != 'true' " Project="$(BuildInfoProps)" />
|
||||
|
||||
<Import Project="build/BranchInfo.props" />
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ if ($NoBuild)
|
|||
}
|
||||
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
|
||||
if($LASTEXITCODE -ne 0) { throw "Failed to build" }
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
|||
echo "${args[@]}"
|
||||
|
||||
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[@]}"
|
||||
else
|
||||
echo "Not building due to --nobuild"
|
||||
|
|
Loading…
Reference in a new issue