question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] GitVersion.MsBuild does not set Azure DevOps build number

See original GitHub issue

Hello,

I have a C# project that uses the GitVersionTask package. The project is built in an Azure DevOps pipeline. When running the build, the Azure DevOps build number is automatically set to the “FullSemVer”. However, after upgrading GitVersionTask to GitVersion.MsBuild, the build number is not set anymore.

Expected Behavior

GitVersion.MsBuild should set the Azure DevOps build number.

Actual Behavior

GitVersion.MsBuild does not set the Azure DevOps build number.

Additional Information

The log shows the following line:

Executing GenerateBuildLogOutput for 'AzurePipelines'.

However, it does not show this line:

Executing GenerateSetVersionMessage for 'AzurePipelines'.

From the git version code (src/GitVersionCore/Core/BuildAgentBase.cs), this indicates that the updateBuildNumber variable is false:

if (updateBuildNumber)
{
    writer($"Executing GenerateSetVersionMessage for '{GetType().Name}'.");
    writer(GenerateSetVersionMessage(variables));
}
writer($"Executing GenerateBuildLogOutput for '{GetType().Name}'.");

I tried adding a GitVersion.yml with update-build-number: true, however, it did not help.

Your Environment

  • Azure DevOps pipeline.
  • Repository does not contain GitVersion.yml. If I run gitversion /showconfig locally, update-build-number is set to true.
  • GitVersion.MsBuild 5.6.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
ddprince-yaksacommented, Jan 21, 2021

Hi,

I found this bug report while looking for this exact problem. We have just switched from GitVersionTask to GitVersion.MsBuild and we have the same issue.

Thanks, David

2reactions
seifcommented, May 27, 2021

I landed here as I was looking for a similar issue I am having with Teamcity. I used the following to get the version in teamcity

  <Target Name="Update teamcity build number" AfterTargets="GetVersion"  Condition="'$(TEAMCITY_VERSION)' != ''">
    <Message Text="##teamcity[buildNumber '$(GitVersion_FullSemVer)']" Importance="High" />
  </Target>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Gitversion rolled back the version number for my NuGet ...
Multiple version of Azure DevOps build pipelines that build 10+ NuGet packages that use GitVersion MsBuild task with Mainline mode configured.
Read more >
Azure DevOps
To use GitVersion's variables in the build name, just add them in the form $(GITVERSION_FullSemVer) into the Build definition's build number string. Then...
Read more >
Azure DevOps Pipeline build not working
Thanks for reporting the issue on Developer Community. This seems to be caused by the upgraded build engine. MSBuild 16.5 has a new...
Read more >
How to use GitVersion to get sensible versioning
A neat trick is that GitVersion understands and detects most build systems and automatically updates the build number reported to TeamCity, ...
Read more >
Gitversion Azure Devops
GitVersion looks at your Git history and works out the semantic version. Azure Devops: SemVer ... [Bug] GitVersion.MsBuild does not set Azure DevOps...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found