Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto increment the version (eg. “1.0.*”) of a .NET Core project?

In the old .NET framework, you could set the [assembly: AssemblyVersion("1.0.*")] and the compiler would auto-increment the version.

With .NET core, I've tried all sorts of things, but I can't get it to auto-increment.

  • I've added <Deterministic>False</Deterministic> and <AssemblyVersion>1.0.*</AssemblyVersion> to the .csproj per similar question. The code compiles but the version stays the same
  • I've tried the same thing but with <Version>1.0.*</Version> tag as described here. This actually set the product version to 1.0.* (with the asterisk).
  • I've set the Assembly Version in the Property Properties/Package page. Doesn't seem to do anything either.

None of it seems to work. Am I missing something simple? This is just a standard .NET Core Web Project.

like image 212
AngryHacker Avatar asked Aug 10 '20 04:08

AngryHacker


2 Answers

As indicated if you follow some of the links from the comments/answers, the most straightforward way to get .NET Framework-like version auto-incrementing in .NET Core 3/5/6 is to add to your .csproj:

<PropertyGroup>
   <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
   <Deterministic>false</Deterministic>
</PropertyGroup>

And add to your Program.cs:

[assembly: System.Reflection.AssemblyVersion("1.0.*")]

You may still want to read the links if there are other AssemblyInfo properties you want to set.

like image 98
pdpc Avatar answered Oct 18 '22 00:10

pdpc


One simple way I did it previously is reading the current version and increase it by one, so you get current version and increment by one using command line.

I found this article would answers your question: https://sachabarbs.wordpress.com/2020/02/23/net-core-standard-auto-incrementing-versioning/

like image 26
Maytham Avatar answered Oct 17 '22 22:10

Maytham