diff --git a/build.proj b/build.proj index 5d0235bb7..e93d45d9c 100644 --- a/build.proj +++ b/build.proj @@ -7,6 +7,9 @@ + $(OverrideArchitecture) + $(OverrideRid) + diff --git a/build/Microsoft.DotNet.Cli.GitCommitInfo.targets b/build/Microsoft.DotNet.Cli.GitCommitInfo.targets index fc50e0b66..60dd42d74 100644 --- a/build/Microsoft.DotNet.Cli.GitCommitInfo.targets +++ b/build/Microsoft.DotNet.Cli.GitCommitInfo.targets @@ -1,34 +1,24 @@ - + + + + + - - - - - - true + Condition=" '$(DefaultCommitCount)' != '$(GitInfoCommitCount)' Or + '$(CommitHash)' != '$(GitInfoCommitHash)' ">true <Project ToolsVersion="15.0"> <PropertyGroup> + <DefaultCommitCount>$(GitInfoCommitCount)</DefaultCommitCount> <CommitHash>$(GitInfoCommitHash)</CommitHash> - <CommitCount>$(GitInfoCommitCount)</CommitCount> - <MsiVersion>$(BuildInfoMsiVersion)</MsiVersion> - <VersionBadgeMoniker>$(BuildInfoVersionBadgeMoniker)</VersionBadgeMoniker> </PropertyGroup> </Project> diff --git a/build/Microsoft.DotNet.Cli.HostInfo.targets b/build/Microsoft.DotNet.Cli.HostInfo.targets index 507c99f17..095ac2c8d 100644 --- a/build/Microsoft.DotNet.Cli.HostInfo.targets +++ b/build/Microsoft.DotNet.Cli.HostInfo.targets @@ -3,7 +3,7 @@ Condition=" !Exists('$(HostInfoProps)') " DependsOnTargets="BuildDotnetCliBuildFramework"> - + diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index 7e4e03b61..f7e181a16 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -16,6 +16,9 @@ + + + diff --git a/build/Microsoft.DotNet.Cli.tasks b/build/Microsoft.DotNet.Cli.tasks index 89c188c72..4f623018a 100644 --- a/build/Microsoft.DotNet.Cli.tasks +++ b/build/Microsoft.DotNet.Cli.tasks @@ -17,12 +17,14 @@ - + + + diff --git a/build/package/Microsoft.DotNet.Cli.Installer.MSI.targets b/build/package/Microsoft.DotNet.Cli.Installer.MSI.targets index 365c15b9b..fb733e0ea 100644 --- a/build/package/Microsoft.DotNet.Cli.Installer.MSI.targets +++ b/build/package/Microsoft.DotNet.Cli.Installer.MSI.targets @@ -31,6 +31,14 @@ + + + + diff --git a/build_projects/dotnet-cli-build/GenerateBuildVersionInfo.cs b/build_projects/dotnet-cli-build/GenerateBuildVersionInfo.cs deleted file mode 100644 index b5704e095..000000000 --- a/build_projects/dotnet-cli-build/GenerateBuildVersionInfo.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; -using System.Runtime.InteropServices; - -namespace Microsoft.DotNet.Cli.Build -{ - public class GenerateBuildVersionInfo : ToolTask - { - [Required] - public string RepoRoot { get; set; } - - [Required] - public int VersionMajor { get; set; } - - [Required] - public int VersionMinor { get; set; } - - [Required] - public int VersionPatch { get; set; } - - [Required] - public string ReleaseSuffix { get; set; } - - [Output] - public string CommitCount { get; set; } - - [Output] - public string VersionSuffix { get; set; } - - [Output] - public string SimpleVersion { get; set; } - - [Output] - public string NugetVersion { get; set; } - - [Output] - public string MsiVersion { get; set; } - - [Output] - public string VersionBadgeMoniker { get; set; } - - private int _commitCount; - - public override bool Execute() - { - base.Execute(); - - var buildVersion = new BuildVersion() - { - Major = VersionMajor, - Minor = VersionMinor, - Patch = VersionPatch, - ReleaseSuffix = ReleaseSuffix, - CommitCount = _commitCount - }; - - CommitCount = buildVersion.CommitCountString; - VersionSuffix = buildVersion.VersionSuffix; - SimpleVersion = buildVersion.SimpleVersion; - NugetVersion = buildVersion.NuGetVersion; - MsiVersion = buildVersion.GenerateMsiVersion(); - VersionBadgeMoniker = Monikers.GetBadgeMoniker(); - - return true; - } - - protected override string ToolName - { - get { return "git"; } - } - - protected override MessageImportance StandardOutputLoggingImportance - { - get { return MessageImportance.High; } // or else the output doesn't get logged by default - } - - protected override string GenerateFullPathToTool() - { - // Workaround: https://github.com/Microsoft/msbuild/issues/1215 - // There's a "git" folder on the PATH in VS 2017 Developer command prompt and it causes msbuild to fail to execute git. - return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "git.exe" : "git"; - } - - protected override string GenerateCommandLineCommands() - { - return $"rev-list --count HEAD"; - } - - protected override void LogEventsFromTextOutput(string line, MessageImportance importance) - { - _commitCount = int.Parse(line); - } - } -} \ No newline at end of file diff --git a/build_projects/dotnet-cli-build/GenerateMsiVersion.cs b/build_projects/dotnet-cli-build/GenerateMsiVersion.cs new file mode 100644 index 000000000..8a4043628 --- /dev/null +++ b/build_projects/dotnet-cli-build/GenerateMsiVersion.cs @@ -0,0 +1,46 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using System.Runtime.InteropServices; + +namespace Microsoft.DotNet.Cli.Build +{ + public class GenerateMsiVersion : Task + { + [Required] + public int CommitCount { get; set; } + + [Required] + public int VersionMajor { get; set; } + + [Required] + public int VersionMinor { get; set; } + + [Required] + public int VersionPatch { get; set; } + + [Required] + public string ReleaseSuffix { get; set; } + + [Output] + public string MsiVersion { get; set; } + + public override bool Execute() + { + var buildVersion = new BuildVersion() + { + Major = VersionMajor, + Minor = VersionMinor, + Patch = VersionPatch, + ReleaseSuffix = ReleaseSuffix, + CommitCount = CommitCount + }; + + MsiVersion = buildVersion.GenerateMsiVersion(); + + return true; + } + } +} diff --git a/build_projects/dotnet-cli-build/GetCommitCount.cs b/build_projects/dotnet-cli-build/GetCommitCount.cs new file mode 100644 index 000000000..b820dd209 --- /dev/null +++ b/build_projects/dotnet-cli-build/GetCommitCount.cs @@ -0,0 +1,42 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using System.Runtime.InteropServices; + +namespace Microsoft.DotNet.Cli.Build +{ + public class GetCommitCount : ToolTask + { + [Output] + public string CommitCount { get; set; } + + protected override string ToolName + { + get { return "git"; } + } + + protected override MessageImportance StandardOutputLoggingImportance + { + get { return MessageImportance.High; } // or else the output doesn't get logged by default + } + + protected override string GenerateFullPathToTool() + { + // Workaround: https://github.com/Microsoft/msbuild/issues/1215 + // There's a "git" folder on the PATH in VS 2017 Developer command prompt and it causes msbuild to fail to execute git. + return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "git.exe" : "git"; + } + + protected override string GenerateCommandLineCommands() + { + return $"rev-list --count HEAD"; + } + + protected override void LogEventsFromTextOutput(string line, MessageImportance importance) + { + CommitCount = line; + } + } +} diff --git a/build_projects/dotnet-cli-build/GetCommitHash.cs b/build_projects/dotnet-cli-build/GetCommitHash.cs index 7e31b45b9..69474f9c1 100644 --- a/build_projects/dotnet-cli-build/GetCommitHash.cs +++ b/build_projects/dotnet-cli-build/GetCommitHash.cs @@ -9,9 +9,6 @@ namespace Microsoft.DotNet.Cli.Build { public class GetCommitHash : ToolTask { - [Required] - public string RepoRoot { get; set; } - [Output] public string CommitHash { get; set; } @@ -42,4 +39,4 @@ namespace Microsoft.DotNet.Cli.Build CommitHash = line; } } -} \ No newline at end of file +} diff --git a/build_projects/dotnet-cli-build/GetCurrentRuntimeInformation.cs b/build_projects/dotnet-cli-build/GetCurrentRuntimeInformation.cs index 76e10d8ab..dbbeaa0de 100644 --- a/build_projects/dotnet-cli-build/GetCurrentRuntimeInformation.cs +++ b/build_projects/dotnet-cli-build/GetCurrentRuntimeInformation.cs @@ -9,8 +9,6 @@ namespace Microsoft.DotNet.Cli.Build { public class GetCurrentRuntimeInformation : Task { - public string OverrideRid { get; set; } - [Output] public string Rid { get; set; } @@ -22,7 +20,7 @@ namespace Microsoft.DotNet.Cli.Build public override bool Execute() { - Rid = string.IsNullOrEmpty(OverrideRid) ? RuntimeEnvironment.GetRuntimeIdentifier() : OverrideRid; + Rid = RuntimeEnvironment.GetRuntimeIdentifier(); Architecture = RuntimeEnvironment.RuntimeArchitecture; OSName = Monikers.GetOSShortName(); diff --git a/build_projects/dotnet-cli-build/GetVersionBadgeMoniker.cs b/build_projects/dotnet-cli-build/GetVersionBadgeMoniker.cs new file mode 100644 index 000000000..b199bc6f7 --- /dev/null +++ b/build_projects/dotnet-cli-build/GetVersionBadgeMoniker.cs @@ -0,0 +1,22 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using System.Runtime.InteropServices; + +namespace Microsoft.DotNet.Cli.Build +{ + public class GetVersionBadgeMoniker : Task + { + [Output] + public string VersionBadgeMoniker { get; set; } + + public override bool Execute() + { + VersionBadgeMoniker = Monikers.GetBadgeMoniker(); + + return true; + } + } +} diff --git a/run-build.ps1 b/run-build.ps1 index 632bbe286..435ea5ceb 100644 --- a/run-build.ps1 +++ b/run-build.ps1 @@ -110,11 +110,11 @@ $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH" if ($NoBuild) { Write-Host "Not building due to --nobuild" - Write-Host "Command that would be run: 'dotnet msbuild build.proj /m /p:Architecture=$Architecture $ExtraParameters'" + Write-Host "Command that would be run: 'dotnet msbuild build.proj /m /p:OverrideArchitecture=$Architecture $ExtraParameters'" } else { - dotnet msbuild build.proj /p:Architecture=$Architecture /p:GeneratingPropsFile=true /t:WriteDynamicPropsToStaticPropsFiles - dotnet msbuild build.proj /m /v:diag /p:Architecture=$Architecture $ExtraParameters + dotnet msbuild build.proj /p:OverrideArchitecture=$Architecture /p:GeneratingPropsFile=true /t:WriteDynamicPropsToStaticPropsFiles + dotnet msbuild build.proj /m /v:diag /p:OverrideArchitecture=$Architecture $ExtraParameters if($LASTEXITCODE -ne 0) { throw "Failed to build" } } diff --git a/run-build.sh b/run-build.sh index 877c5b547..bebcd7670 100755 --- a/run-build.sh +++ b/run-build.sh @@ -179,9 +179,9 @@ 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 /m /v:diag /p:Architecture=$ARCHITECTURE "${args[@]}" + dotnet msbuild build.proj /p:OverrideArchitecture=$ARCHITECTURE /p:GeneratingPropsFile=true /t:WriteDynamicPropsToStaticPropsFiles + dotnet msbuild build.proj /m /v:diag /p:OverrideArchitecture=$ARCHITECTURE "${args[@]}" else echo "Not building due to --nobuild" - echo "Command that would be run is: 'dotnet msbuild build.proj /m /p:Architecture=$ARCHITECTURE ${args[@]}'" + echo "Command that would be run is: 'dotnet msbuild build.proj /m /p:OverrideArchitecture=$ARCHITECTURE ${args[@]}'" fi