From aff23d00f46c6c4a112e33017345e9f0df485be4 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Tue, 28 Jun 2016 18:19:42 -0500 Subject: [PATCH 1/3] Implement RestorePackages in MSBuild. This adds the DotNetTool custom task, with `dotnet restore` implemented. --- build/Microsoft.DotNet.Cli.Prepare.targets | 21 ++++- build_projects/dotnet-cli-build/DotNetTool.cs | 85 +++++++++++++++++++ 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 build_projects/dotnet-cli-build/DotNetTool.cs diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index 7de75544f..32321e43d 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -5,12 +5,13 @@ + - + @@ -20,6 +21,10 @@ + $(RepoRoot)/.dotnet_stage0/Windows/$(Architecture) + $(RepoRoot)/.dotnet_stage0/$(OSName) + $(Stage0Path) + $(RepoRoot)/artifacts/$(Rid) $(BaseOutputDirectory)/stage2 $(BaseOutputDirectory)/stage2compilation @@ -95,4 +100,18 @@ + + + + + + + + + + + + diff --git a/build_projects/dotnet-cli-build/DotNetTool.cs b/build_projects/dotnet-cli-build/DotNetTool.cs new file mode 100644 index 000000000..d3d8581b7 --- /dev/null +++ b/build_projects/dotnet-cli-build/DotNetTool.cs @@ -0,0 +1,85 @@ +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace Microsoft.DotNet.Cli.Build +{ + public abstract class DotNetTool : ToolTask + { + private const string ExeName = "dotnet.exe"; + + public DotNetTool() + { + } + + protected abstract string Command { get; } + + protected abstract string Args { get; } + + public string WorkingDirectory { get; set; } + + protected override string ToolName + { + get { return ExeName; } + } + + protected override MessageImportance StandardOutputLoggingImportance + { + get { return MessageImportance.High; } // or else the output doesn't get logged by default + } + + protected override string GenerateFullPathToTool() + { + string path = ToolPath; + + // if ToolPath was not provided by the MSBuild script + if (string.IsNullOrEmpty(path)) + { + Log.LogError($"Could not find the Path to {ExeName}"); + + return string.Empty; + } + + return path; + } + + protected override string GetWorkingDirectory() + { + return WorkingDirectory ?? base.GetWorkingDirectory(); + } + + protected override string GenerateCommandLineCommands() + { + return $"{Command} {Args}"; + } + + protected override void LogToolCommand(string message) + { + base.LogToolCommand($"{GetWorkingDirectory()}> {message}"); + } + } + + public class DotNetRestore : DotNetTool + { + protected override string Command + { + get { return "restore"; } + } + + protected override string Args + { + get { return $"{GetVerbosity()}"; } + } + + public string Verbosity { get; set; } + + private string GetVerbosity() + { + if (!string.IsNullOrEmpty(Verbosity)) + { + return $"--verbosity {Verbosity}"; + } + + return null; + } + } +} From bf172df39b2877f075b4a4096aefa34439272e5d Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Tue, 28 Jun 2016 18:59:15 -0500 Subject: [PATCH 2/3] Respond to PR feedback and fix CommitCount not being padded with zeros. --- build/Microsoft.DotNet.Cli.Prepare.targets | 8 +------- .../dotnet-cli-build/GenerateBuildVersionInfo.cs | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index 32321e43d..b53cfcd3c 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -103,15 +103,9 @@ - - - - - + diff --git a/build_projects/dotnet-cli-build/GenerateBuildVersionInfo.cs b/build_projects/dotnet-cli-build/GenerateBuildVersionInfo.cs index 1328998aa..2be4c2a5c 100644 --- a/build_projects/dotnet-cli-build/GenerateBuildVersionInfo.cs +++ b/build_projects/dotnet-cli-build/GenerateBuildVersionInfo.cs @@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Cli.Build public string CommitHash { get; set; } [Output] - public int CommitCount { get; set; } + public string CommitCount { get; set; } [Output] public string ReleaseSuffix { get; set; } @@ -68,7 +68,7 @@ namespace Microsoft.DotNet.Cli.Build VersionMinor = buildVersion.Minor; VersionPatch = buildVersion.Patch; CommitHash = commitHash; - CommitCount = commitCount; + CommitCount = buildVersion.CommitCountString; ReleaseSuffix = buildVersion.ReleaseSuffix; VersionSuffix = buildVersion.VersionSuffix; SimpleVersion = buildVersion.SimpleVersion; From a7d2972509341c87f67832cd2c0079138305babd Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Tue, 28 Jun 2016 19:03:10 -0500 Subject: [PATCH 3/3] Fix Stage0 calculation on Unix. --- build/Microsoft.DotNet.Cli.Prepare.targets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index b53cfcd3c..72a830da7 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -22,7 +22,8 @@ $(RepoRoot)/.dotnet_stage0/Windows/$(Architecture) - $(RepoRoot)/.dotnet_stage0/$(OSName) + $(RepoRoot)/.dotnet_stage0/Darwin + $(RepoRoot)/.dotnet_stage0/Linux $(Stage0Path) $(RepoRoot)/artifacts/$(Rid)