From d2e7eee36f9d203add5af1471bab2d9d304a7670 Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Wed, 16 Oct 2024 14:07:06 -0700 Subject: [PATCH] Ensure GetBuildVersion runs before Clean --- .../build/Nerdbank.GitVersioning.targets | 5 +++++ .../Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets index 4cba9f6f..0fa3bb88 100644 --- a/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets +++ b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets @@ -8,6 +8,11 @@ $(VersionDependsOn) + + GetBuildVersion; + $(CleanDependsOn) + + GetBuildVersion; $(GenerateNuspecDependsOn) diff --git a/test/Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs b/test/Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs index de6b10b0..104a7439 100644 --- a/test/Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs +++ b/test/Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs @@ -131,6 +131,14 @@ public async Task GetBuildVersion_Without_Git() Assert.Equal("3.4.0", buildResult.AssemblyInformationalVersion); } + [Fact] + public async Task GetBuildVersion_Hooks_Clean() + { + this.WriteVersionFile("1.2"); + BuildResults buildResult = await this.BuildAsync("Clean"); + Assert.Equal("1.2", buildResult.BuildVersion); + } + [Fact] public async Task GetBuildVersion_Without_Git_HighPrecisionAssemblyVersion() {