From 9623cc4ad1ab8b0f47d13c76c1d06943b0dcafc6 Mon Sep 17 00:00:00 2001 From: Artur Date: Wed, 21 Dec 2022 12:05:54 +0100 Subject: [PATCH] dogfood GitVersion to handle breaking changes --- GitVersion.yml | 4 +- build/build/Tasks/ValidateVersion.cs | 1 - build/common/Lifetime/BuildLifetimeBase.cs | 34 +++++++++++++-- dotnet-tools.json | 50 ++++++++++------------ 4 files changed, 55 insertions(+), 34 deletions(-) diff --git a/GitVersion.yml b/GitVersion.yml index 8cb4734ffc..08802473ca 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,6 +1,6 @@ assembly-versioning-scheme: MajorMinorPatch branches: main: - tag: beta + label: beta support: - tag: beta + label: beta diff --git a/build/build/Tasks/ValidateVersion.cs b/build/build/Tasks/ValidateVersion.cs index c0545f18f3..a73ad7c87c 100644 --- a/build/build/Tasks/ValidateVersion.cs +++ b/build/build/Tasks/ValidateVersion.cs @@ -1,4 +1,3 @@ -using Build.Utilities; using Common.Utilities; namespace Build.Tasks; diff --git a/build/common/Lifetime/BuildLifetimeBase.cs b/build/common/Lifetime/BuildLifetimeBase.cs index fe98354586..b07b91035d 100644 --- a/build/common/Lifetime/BuildLifetimeBase.cs +++ b/build/common/Lifetime/BuildLifetimeBase.cs @@ -24,10 +24,17 @@ public override void Setup(T context, ISetupContext info) context.IsOnLinux = context.IsRunningOnLinux(); context.IsOnMacOS = context.IsRunningOnMacOs(); - var gitVersion = context.GitVersion(new GitVersionSettings + BuildSolution(context); + + var gitversionTool = context.GetGitVersionToolLocation(); + var gitVersionSettings = new GitVersionSettings { - OutputTypes = new HashSet { GitVersionOutput.Json, GitVersionOutput.BuildServer } - }); + OutputTypes = new HashSet { GitVersionOutput.Json, GitVersionOutput.BuildServer }, + ToolPath = context.Tools.Resolve(new[] { "dotnet.exe", "dotnet" }), + ArgumentCustomization = args => args.Prepend(gitversionTool!.FullPath) + }; + + var gitVersion = context.GitVersion(gitVersionSettings); context.Version = BuildVersion.Calculate(gitVersion); } @@ -69,4 +76,25 @@ protected void LogBuildInformation(T context) context.Information("Support Branch: {0}", context.IsSupportBranch); context.Information("Tagged: {0}", context.IsTagged); } + private static void BuildSolution(T context) + { + context.Information("Builds solution..."); + + const string sln = "./src/GitVersion.sln"; + + context.DotNetRestore(sln, + new() + { + Verbosity = DotNetVerbosity.Minimal, + Sources = new[] { "https://api.nuget.org/v3/index.json" }, + }); + + context.DotNetBuild(sln, + new() + { + Verbosity = DotNetVerbosity.Minimal, + Configuration = Constants.DefaultConfiguration, + NoRestore = true, + }); + } } diff --git a/dotnet-tools.json b/dotnet-tools.json index 99c2335b54..baca618fe5 100644 --- a/dotnet-tools.json +++ b/dotnet-tools.json @@ -1,30 +1,24 @@ { - "version": 1, - "isRoot": true, - "tools": { - "codecov.tool": { - "version": "1.13.0", - "commands": [ - "codecov" - ] - }, - "gitversion.tool": { - "version": "5.11.1", - "commands": [ - "dotnet-gitversion" - ] - }, - "gitreleasemanager.tool": { - "version": "0.13.0", - "commands": [ - "dotnet-gitreleasemanager" - ] - }, - "Wyam2": { - "version": "3.0.0", - "commands": [ - "wyam2" - ] - } + "version": 1, + "isRoot": true, + "tools": { + "codecov.tool": { + "version": "1.13.0", + "commands": [ + "codecov" + ] + }, + "gitreleasemanager.tool": { + "version": "0.13.0", + "commands": [ + "dotnet-gitreleasemanager" + ] + }, + "wyam2": { + "version": "3.0.0", + "commands": [ + "wyam2" + ] } -} + } +} \ No newline at end of file