From 8eb77c8d35b2a62a0aa6b7deb1536185989a5d92 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Thu, 27 Feb 2020 12:27:04 +0200 Subject: [PATCH 1/2] GH-2101 - (build) set assembly version on build --- build/utils/utils.cake | 2 -- src/GitVersionCore/Extensions/AssemblyInfo.cs | 7 ------- src/GitVersionCore/GitVersionCore.csproj | 1 - src/GitVersionExe/AssemblyInfo.cs | 7 ------- src/GitVersionExe/GitVersionExe.csproj | 1 - 5 files changed, 18 deletions(-) diff --git a/build/utils/utils.cake b/build/utils/utils.cake index cac07342a8..38c702bba9 100644 --- a/build/utils/utils.cake +++ b/build/utils/utils.cake @@ -84,7 +84,6 @@ public static List ExecGitCmd(this ICakeContext context, string cmd) return redirectedOutput.ToList(); } - DirectoryPath HomePath() { return IsRunningOnWindows() @@ -129,7 +128,6 @@ void RunGitVersionOnCI(BuildParameters parameters) { var settings = new GitVersionSettings { - UpdateAssemblyInfo = true, LogFilePath = "console", OutputType = GitVersionOutput.BuildServer }; diff --git a/src/GitVersionCore/Extensions/AssemblyInfo.cs b/src/GitVersionCore/Extensions/AssemblyInfo.cs index 967d567a6a..7c1dbae9b9 100644 --- a/src/GitVersionCore/Extensions/AssemblyInfo.cs +++ b/src/GitVersionCore/Extensions/AssemblyInfo.cs @@ -1,13 +1,6 @@ -using System.Reflection; using System.Runtime.CompilerServices; -[assembly: AssemblyTitle("GitVersionCore")] -[assembly: AssemblyProduct("GitVersion")] -[assembly: AssemblyVersion("4.0.0.0")] -[assembly: AssemblyFileVersion("4.0.0.0")] [assembly: InternalsVisibleTo("GitVersionTask.Tests")] [assembly: InternalsVisibleTo("GitVersion")] [assembly: InternalsVisibleTo("GitVersionCore.Tests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] - -[assembly: AssemblyInformationalVersion("4.0.0+Branch.master.Sha.e715eb5dd515037d90a257f527e62442cae8c1c5")] diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index 2a11d071b1..825087dcad 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -3,7 +3,6 @@ netstandard2.0 GitVersion - false bin\$(Configuration)\GitVersionCore.xml 1591 diff --git a/src/GitVersionExe/AssemblyInfo.cs b/src/GitVersionExe/AssemblyInfo.cs index c441c4413c..32cf4f2a22 100644 --- a/src/GitVersionExe/AssemblyInfo.cs +++ b/src/GitVersionExe/AssemblyInfo.cs @@ -1,12 +1,5 @@ -using System.Reflection; using System.Runtime.CompilerServices; -[assembly: AssemblyTitle("GitVersion")] -[assembly: AssemblyProduct("GitVersion")] -[assembly: AssemblyVersion("4.0.0.0")] -[assembly: AssemblyFileVersion("4.0.0.0")] [assembly: InternalsVisibleTo("GitVersionTask.Tests")] [assembly: InternalsVisibleTo("AcceptanceTests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] - -[assembly: AssemblyInformationalVersion("4.0.0+Branch.master.Sha.e715eb5dd515037d90a257f527e62442cae8c1c5")] diff --git a/src/GitVersionExe/GitVersionExe.csproj b/src/GitVersionExe/GitVersionExe.csproj index cec50b009a..9cb1cc0f62 100644 --- a/src/GitVersionExe/GitVersionExe.csproj +++ b/src/GitVersionExe/GitVersionExe.csproj @@ -5,7 +5,6 @@ GitVersion GitVersion netcoreapp2.1;netcoreapp3.1 - false AnyCPU MIT bin\$(Configuration)\GitVersion.xml From 31bc492738a0d8d6298ee82d5c9bc9952f4ef991 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Wed, 26 Feb 2020 19:19:11 +0200 Subject: [PATCH 2/2] GH-2101 - (build) add assertion that the version is set correctly --- build/pack.cake | 9 ++++++++- build/utils/utils.cake | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/build/pack.cake b/build/pack.cake index 342ed6dcaf..6d4e66c160 100644 --- a/build/pack.cake +++ b/build/pack.cake @@ -21,11 +21,18 @@ Task("Build") RunGitVersionOnCI(parameters); }); +Task("Validate-Version") + .IsDependentOn("Build") + .Does((parameters) => +{ + ValidateVersion(parameters); +}); + #endregion #region Pack Task("Pack-Prepare") - .IsDependentOn("Build") + .IsDependentOn("Validate-Version") .Does((parameters) => { // publish single file for all native runtimes (self contained) diff --git a/build/utils/utils.cake b/build/utils/utils.cake index 38c702bba9..cb54e56f6d 100644 --- a/build/utils/utils.cake +++ b/build/utils/utils.cake @@ -121,6 +121,24 @@ GitVersion GetVersion(BuildParameters parameters) return gitVersion; } +void ValidateVersion(BuildParameters parameters) +{ + var gitVersionTool = GetFiles($"artifacts/**/bin/{parameters.CoreFxVersion31}/GitVersion.dll").FirstOrDefault(); + IEnumerable output; + var fullFxResult = StartProcess( + "dotnet", + new ProcessSettings { + Arguments = $"\"{gitVersionTool}\" -version", + RedirectStandardOutput = true, + }, + out output + ); + + var outputStr = string.Concat(output); + + Assert.Equal(parameters.Version.SemVersion, outputStr); +} + void RunGitVersionOnCI(BuildParameters parameters) { // set the CI build version number with GitVersion