Click here to Skip to main content
15,883,416 members
Articles / DevOps

.NET Core Versioning Demystified

Rate me:
Please Sign up or sign in to vote.
4.85/5 (14 votes)
19 Mar 2020CPOL2 min read 26.7K   23   11
Version all your .NET Core projects in one swoop fell!
In this tip, you will learn an easy way to provide a common version number and version information for your .NET Core 2.0 projects.


We have a VS2017 solution containing hundreds of projects, mostly in C#.
The build process is automated using mostly free tools:

  • Gitea GIT server
  • Continuous integration builder running TeamCity

The C# projects are versioned using the 'VersionInfo.cs' trick, which means that there is one central version file that is added as a link in all projects in the Visual Studio solution explorer.
This trick is described here.

We use a custom 'AutoBuildVersion' tool that modifies the contents of the 'VersionInfo.cs' file (and also other files like Visual C .rc files).
Sadly, I cannot disclose the source code of this tool, but there is a good alternative mentioned at the bottom of this tip.

So far, so good, until recently .NET Core and .NET Standard projects started popping up that have a totally different way of storing version information.
Instead of using traditional AssemblyInfo.cs files, for .NET Core 2.0 projects, the version information in now stored in the .csproj files.

Using the Code

After hunting the internet for days, I finally stumbled on this tip, a Directory.Build.props file that will version all .NET Core directories beneath it, example:

    <Authors>Zeeland BV</Authors>
    <Company>Zeeland BV</Company>
    <Copyright>Zeeland BV</Copyright>

I also posted my issue on the dotnet/coreclr GitHub site and got this interesting answer about a Common.props file:

    <!-- etc.... -->

Then in your .csproj, add <Import Project="..\..\Common.props" /> right after the <project> element opener.

But I think I will stick with the first solution of a Directory.Build.props file as this seems to be the easiest option for me.

Points of Interest

Other interesting tools:


  • 19th March, 2020: V 1.0


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer
Netherlands Netherlands
Software developer in the Netherlands, currently working on Video Surveillance applications.
Experience: C#, C++, VB, ASP, SQL Server, PostgreSQL, Gitea, TeamCity.
It all started with Black&White, no not the whiskey but the Sinclair ZX81 followed by several Atari's and PC's. The journey continues ...

Comments and Discussions

QuestionCode snippet for changing AssemblyVersion and AssemblyFileVersion Pin
Qwertie23-Apr-20 16:41
Qwertie23-Apr-20 16:41 
QuestionCode snippet for changing AssemblyVersion and AssemblyFileVersion Pin
Qwertie23-Apr-20 16:41
Qwertie23-Apr-20 16:41 
PraiseRe: Code snippet for changing AssemblyVersion and AssemblyFileVersion Pin
RickZeeland23-Apr-20 19:36
mveRickZeeland23-Apr-20 19:36 
GeneralMy vote of 5 Pin
raddevus21-Apr-18 8:34
mvaraddevus21-Apr-18 8:34 
GeneralMy vote of 5 Pin
L Hills26-Feb-18 3:16
L Hills26-Feb-18 3:16 
GeneralRe: My vote of 5 Pin
RickZeeland26-Feb-18 5:39
mveRickZeeland26-Feb-18 5:39 
SuggestionA questions and a proposition... Pin
Kornfeld Eliyahu Peter25-Feb-18 20:36
professionalKornfeld Eliyahu Peter25-Feb-18 20:36 
GeneralRe: A questions and a proposition... Pin
RickZeeland25-Feb-18 22:31
mveRickZeeland25-Feb-18 22:31 
GeneralRe: A questions and a proposition... Pin
Kirk Wood21-Mar-20 3:55
Kirk Wood21-Mar-20 3:55 
GeneralRe: A questions and a proposition... Pin
RickZeeland21-Mar-20 4:25
mveRickZeeland21-Mar-20 4:25 
Luckily for our newest software the restraint to have all assemblies set to the same version has been lifted. We have a very large Codec.dll that takes ages to build, so we don't want to build that every time with the solution. There were also thoughts of putting it in a NuGet package, but sadly our CI system (TeamCity) was not the ideal NuGet server, maybe in the future we will build our own NuGet server with the freely available Sonatype Nexus for instance.
GeneralRe: A questions and a proposition... Pin
johannesnestler19-Mar-20 23:57
johannesnestler19-Mar-20 23:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.