.NET Core: Using AssemblyInfo shared between assemblies

There was a time when project.json has replaced the AssemblyInfo. But since .NET core uses .csproj, instead of the project.json, AssemblyInfo comes to the development again.

If you want to version your several different assemblies together, then follow this tutorial.

Add a shared AssemblyInfo.cs

Right click on your solution, and select Add > New Item..

In the following screen, select Visual C# class, and name it as ‘AssemblyInfo.cs’

Replace the file content with the example below:

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following 
// associated with an assembly.
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyDescription("Insert your description here")]
[assembly: AssemblyCompany("YourAwesomeCompany")]
[assembly: AssemblyCopyright("Copyright © YourAwesomeCompany 2021")]

Set your projects to use the shared assembly info

Do this all of your projects where you want to use the shared assembly info file.

Edit your project file with a text editor (or right click on project > Edit project file)

Add the following tag to the PropertyGroup tag in order to diable automatic assemblyinfo.cs generation:


Add the shared assembly info to be used with inserting the following tags to between the project tags:

    <Compile Include="..\AssemblyInfo.cs" Link="Properties\AssemblyInfo.cs" />

If the project has no Properties folder, like .NET Standard projects basically do, then add the new folder also with this snippet:

    <Folder Include="Properties\" />