From fbb75e1a471531d818bdf0433fec9c4ba7a6e520 Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Thu, 2 Mar 2017 18:46:08 -0800 Subject: [PATCH] Remove task usage in commitcount calculation --- build/GitCommitInfo.targets | 17 +++---- build/Microsoft.DotNet.Cli.tasks | 2 - .../dotnet-cli-build/GetCommitCount.cs | 47 ------------------- .../dotnet-cli-build/GetCommitHash.cs | 42 ----------------- 4 files changed, 9 insertions(+), 99 deletions(-) delete mode 100644 build_projects/dotnet-cli-build/GetCommitCount.cs delete mode 100644 build_projects/dotnet-cli-build/GetCommitHash.cs diff --git a/build/GitCommitInfo.targets b/build/GitCommitInfo.targets index aa997e232..3631da0fa 100644 --- a/build/GitCommitInfo.targets +++ b/build/GitCommitInfo.targets @@ -1,13 +1,14 @@ - - - - + + + + - - - + + + - - diff --git a/build_projects/dotnet-cli-build/GetCommitCount.cs b/build_projects/dotnet-cli-build/GetCommitCount.cs deleted file mode 100644 index a160792ce..000000000 --- a/build_projects/dotnet-cli-build/GetCommitCount.cs +++ /dev/null @@ -1,47 +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 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) - { - var buildVersion = new BuildVersion() - { - CommitCount = int.Parse(line) - }; - - CommitCount = buildVersion.CommitCountString; - } - } -} diff --git a/build_projects/dotnet-cli-build/GetCommitHash.cs b/build_projects/dotnet-cli-build/GetCommitHash.cs deleted file mode 100644 index 69474f9c1..000000000 --- a/build_projects/dotnet-cli-build/GetCommitHash.cs +++ /dev/null @@ -1,42 +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 GetCommitHash : ToolTask - { - [Output] - public string CommitHash { 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-parse HEAD"; - } - - protected override void LogEventsFromTextOutput(string line, MessageImportance importance) - { - CommitHash = line; - } - } -}