12

I'm developing a REST API using ASP.NET Core and want the version number to be automatically incremented. This used to be easily by the following pattern in the AssemblyInfo file: [assembly: AssemblyVersion("1.6.*")].

I have read a couple of suggestions to use gulp or other third party tools to accomplish this, like the answer here

But do I really need a third party tool to get automatically increased version number? Is there no longer a built-in feature to support this? It feels like I'm missing something here.

Community
  • 1
  • 1
Janni Kajbrink
  • 661
  • 2
  • 7
  • 21

1 Answers1

5

if you call dotnet build /p:Version=YourVersionNumberHere, the build will also set the assembly version. So in your build scripts you can easily read the current build number and set it as the patch.

For example in appveyor the build number is exposed as a variable called APPVEYOR_BUILD_NUMBER, so if you were to use powershell you could call dotnet build /p:Version=1.0.$env:APPVEYOR_BUILD_NUMBER

I do something similar with appveyor here, where I set the version number of my nuget package to be the github tag name, and I set the tag name to be a version. So when I want to do a release I just make a github tag of 1.1.0 for example, and it gets published to nuget.

TerribleDev
  • 2,195
  • 1
  • 19
  • 31