VSTS/Azure DevOps: Auto-Increment NuGet Package Version on Pack

The_Chud picture The_Chud · Sep 13, 2018 · Viewed 15.5k times · Source

Running the .NET Core Pack task, how do I get the outputted NuGet package version to auto-increment itself?

So, for example, if my current version is 1.0.0, then the next time I call the Pack task, I would like to see 1.0.1.

I'm using environment build variables with Build.BuildNumber and getting outputs at the moment of e.g. 20180913-.2.0, etc. I would like to establish to a more traditional versioning system.

Answer

The_Chud picture The_Chud · Sep 13, 2018

I may have figured it out. For anyone tearing their hair out, try this:

Pack Task:

  • Automatic Package Versioning: Use an environment variable
  • Environment variable: Build.BuildNumber

Then, up in the top menu where you have Tasks, Variables, Triggers, Options, click Options and set:

  • Build number format: 1.0$(Rev:.r)

Save and queue. This will produce e.g. 1.0.1.

(Please Correct me if I am wrong, or if this does not work long-term.)