GitVersion: GitVersionTask fails when building from a tag
Describe the bug I’m using GitHub actions to create a new build of a project that is using GitVersionTask.
When the build runs on a branch, everything works fine. When it runs for a tag, the following error is outputted.
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(46,9): warning : 2020-05-31 05:47:23 WARN [05/31/20 5:47:23:62] Failed to inherit
Increment branch configuration, no branches found. [/src/Core/Core.csproj]
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(46,9): warning : Falling back to master branch config [/src/Core/Core.csproj]
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(46,9): warning : [/src/Core/Core.csproj]
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(46,9): warning : It looks like the branch being examined is a detached Head pointing to commit '87436ac'. Without a proper branch name GitVersion cannot determine the build version. [/src/Core/Core.csproj]
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(10,9): warning : 2020-05-31 05:47:24 WARN [05/31/20 5:47:24:60] Failed to inherit
Increment branch configuration, no branches found. [/src/Core/Core.csproj]
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(10,9): warning : Falling back to master branch config [/src/Core/Core.csproj]
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(10,9): warning : [/src/Core/Core.csproj]
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(10,9): warning : It looks like the branch being examined is a detached Head pointing to commit '87436ac'. Without a proper branch name GitVersion cannot determine the build version. [/src/Core/Core.csproj]
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(71,9): warning : 2020-05-31 05:47:24 WARN [05/31/20 5:47:24:68] Failed to inherit
Increment branch configuration, no branches found. [/src/Core/Core.csproj]
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(71,9): warning : Falling back to master branch config [/src/Core/Core.csproj]
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(71,9): warning : [/src/Core/Core.csproj]
/root/.nuget/packages/gitversiontask/5.3.5/build/GitVersionTask.targets(71,9): warning : It looks like the branch being examined is a detached Head pointing to commit '87436ac'. Without a proper branch name GitVersion cannot determine the build version. [/src/Core/Core.csproj]
/usr/share/dotnet/sdk/2.2.207/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.GenerateAssemblyInfo.targets(161,5): error MSB4044: The "GetAssemblyVersion" task was not given a value for the required parameter "NuGetVersion". [/src/Core/Core.csproj]
/usr/share/dotnet/sdk/2.2.207/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.GenerateAssem
GitVersion standalone works fine when checking out the tag.
Expected Behavior
The build completes with the correct version as per the tag
Actual Behavior
GitVersionTask fails with the above error
Steps to Reproduce
Run a build of a .NET Core 2.2 project in Docker using GitVersionTask 3.3.5
Context
Unable to complete build
Your Environment
GitVersionTask 5.3.5 Build running in a Docker container using mcr.microsoft.com/dotnet/core/sdk:2.2
GitVersion.yml
assembly-versioning-scheme: MajorMinorPatchTag
assembly-file-versioning-scheme: MajorMinorPatchTag
mode: ContinuousDeployment
continuous-delivery-fallback-tag: ""
branches:
master:
mode: ContinuousDeployment
tag: "ci"
increment: Minor
track-merge-target: true
tracks-release-branches: true
is-release-branch: false
prevent-increment-of-merged-branch-version: false
release:
regex: release?[/]
mode: ContinuousDeployment
increment: Patch
is-release-branch: true
prevent-increment-of-merged-branch-version: true
ignore:
sha: []
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 30 (16 by maintainers)
In my case I can reproduce the error like this:
Now run GitVersion and it will fail:
I’m facing the same issue as @jogivanknobi. The smallest steps to reproduce I could find are:
Tested on 3.0.0, 3.6.2, 4.0.0, 5.0.1 and 5.3.7. They all result in an error. (Showing output of 5.3.7 here)
Note that I’m not using an upstream repo, nor a CI server. When you leave the
git branch task1
out, it works fine.After setting the Git_Branch environment variable to (fake) value
%teamcity.build.vcs.branch.1%
, I’m getting the same error. Let me know if you want me to log this as a separate issue.I was using the GitVersion GitHub action and doing a
git fetch --prune --unshallow
as per the GitVersion GitHub actions step documentation.Running the standalone .exe locally also worked fine on the tag.
To fix the issue, I have since changed the checkout step to the following: