Generate host and build info and store them in .props files
This commit is contained in:
parent
da15d5435f
commit
83b46ebc17
5 changed files with 81 additions and 2 deletions
39
build/Microsoft.DotNet.Cli.BuildInfo.targets
Normal file
39
build/Microsoft.DotNet.Cli.BuildInfo.targets
Normal file
|
@ -0,0 +1,39 @@
|
|||
<Project ToolsVersion="15.0">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.tasks))\dir.tasks" />
|
||||
|
||||
<Target Name="WriteBuildInfoProps"
|
||||
Condition=" !Exists('$(BuildInfoProps)') ">
|
||||
<GetCommitHash RepoRoot="$(RepoRoot)">
|
||||
<Output TaskParameter="CommitHash" PropertyName="CommitHash" />
|
||||
</GetCommitHash>
|
||||
|
||||
<GenerateBuildVersionInfo RepoRoot="$(RepoRoot)"
|
||||
VersionMajor="$(VersionMajor)"
|
||||
VersionMinor="$(VersionMinor)"
|
||||
VersionPatch="$(VersionPatch)"
|
||||
ReleaseSuffix="$(ReleaseSuffix)">
|
||||
<Output TaskParameter="CommitCount" PropertyName="CommitCount" />
|
||||
<Output TaskParameter="MsiVersion" PropertyName="MsiVersion" />
|
||||
<Output TaskParameter="VersionBadgeMoniker" PropertyName="VersionBadgeMoniker" />
|
||||
</GenerateBuildVersionInfo>
|
||||
|
||||
<PropertyGroup>
|
||||
<BuildInfoPropsContent>
|
||||
<Project ToolsVersion="15.0">
|
||||
<PropertyGroup>
|
||||
<BuildCommitHash>$(CommitHash)</BuildCommitHash>
|
||||
<BuildCommitCount>$(CommitCount)</BuildCommitCount>
|
||||
<BuildMsiVersion>$(MsiVersion)</BuildMsiVersion>
|
||||
<BuildVersionBadgeMoniker>$(VersionBadgeMoniker)</BuildVersionBadgeMoniker>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</BuildInfoPropsContent>
|
||||
</PropertyGroup>
|
||||
|
||||
<MakeDir Directories="$(RepoRoot)/obj"/>
|
||||
|
||||
<WriteLinesToFile File="$(BuildInfoProps)"
|
||||
Lines="$(BuildInfoPropsContent)" />
|
||||
</Target>
|
||||
</Project>
|
30
build/Microsoft.DotNet.Cli.HostInfo.targets
Normal file
30
build/Microsoft.DotNet.Cli.HostInfo.targets
Normal file
|
@ -0,0 +1,30 @@
|
|||
<Project ToolsVersion="15.0">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.tasks))\dir.tasks" />
|
||||
|
||||
<Target Name="WriteHostInfoProps"
|
||||
Condition=" !Exists('$(HostInfoProps)') ">
|
||||
<GetCurrentRuntimeInformation>
|
||||
<Output TaskParameter="Rid" PropertyName="Rid" />
|
||||
<Output TaskParameter="Architecture" PropertyName="Architecture" />
|
||||
<Output TaskParameter="OSName" PropertyName="OSName" />
|
||||
</GetCurrentRuntimeInformation>
|
||||
|
||||
<PropertyGroup>
|
||||
<HostInfoPropsContent>
|
||||
<Project ToolsVersion="15.0">
|
||||
<PropertyGroup>
|
||||
<HostRid>$(Rid)</HostRid>
|
||||
<HostArchitecture>$(Architecture)</HostArchitecture>
|
||||
<HostOSName>$(OSName)</HostOSName>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</HostInfoPropsContent>
|
||||
</PropertyGroup>
|
||||
|
||||
<MakeDir Directories="$(RepoRoot)/obj"/>
|
||||
|
||||
<WriteLinesToFile File="$(HostInfoProps)"
|
||||
Lines="$(HostInfoPropsContent)" />
|
||||
</Target>
|
||||
</Project>
|
10
dir.props
10
dir.props
|
@ -1,10 +1,17 @@
|
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Condition=" Exists('obj/Microsoft.DotNet.Cli.BuildInfo.props') "
|
||||
Project="obj/Microsoft.DotNet.Cli.BuildInfo.props" />
|
||||
<Import Condition=" Exists('obj/Microsoft.DotNet.Cli.HostInfo.props') "
|
||||
Project="obj/Microsoft.DotNet.Cli.HostInfo.props" />
|
||||
<Import Project="build/Microsoft.DotNet.Cli.DependencyVersions.props" />
|
||||
|
||||
<!-- NuGet Information -->
|
||||
<PropertyGroup>
|
||||
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
|
||||
|
||||
|
||||
<BuildInfoProps>$(RepoRoot)/obj/BuildInfo.props</BuildInfoProps>
|
||||
<HostInfoProps>$(RepoRoot)/obj/HostInfo.props</HostInfoProps>
|
||||
|
||||
<NuGetPackagesDir>$(NUGET_PACKAGES)</NuGetPackagesDir>
|
||||
<NuGetPackagesDir Condition=" '$(NuGetPackagesDir)' == '' ">$(RepoRoot)/.nuget/packages</NuGetPackagesDir>
|
||||
|
||||
|
@ -21,6 +28,5 @@
|
|||
<CliVersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)-$(ReleaseSuffix)</CliVersionPrefix>
|
||||
|
||||
<CliTargetFramework>netcoreapp2.0</CliTargetFramework>
|
||||
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
@ -114,6 +114,8 @@ if ($NoBuild)
|
|||
}
|
||||
else
|
||||
{
|
||||
dotnet msbuild build\Microsoft.DotNet.Cli.BuildInfo.targets /t:WriteBuildInfoProps
|
||||
dotnet msbuild build\Microsoft.DotNet.Cli.HostInfo.targets /t:WriteHostInfoProps
|
||||
dotnet msbuild build.proj /m /v:diag /p:Architecture=$Architecture $ExtraParameters
|
||||
if($LASTEXITCODE -ne 0) { throw "Failed to build" }
|
||||
}
|
||||
|
|
|
@ -179,6 +179,8 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
|||
echo "${args[@]}"
|
||||
|
||||
if [ $BUILD -eq 1 ]; then
|
||||
dotnet msbuild build/Microsoft.DotNet.Cli.BuildInfo.targets /t:WriteBuildInfoProps
|
||||
dotnet msbuild build/Microsoft.DotNet.Cli.HostInfo.targets /t:WriteHostInfoProps
|
||||
dotnet msbuild build.proj /m /v:diag /p:Architecture=$ARCHITECTURE "${args[@]}"
|
||||
else
|
||||
echo "Not building due to --nobuild"
|
||||
|
|
Loading…
Reference in a new issue