Tuesday, July 10, 2018

GlobalAssemblyInfo in .NET Core/Standard applications

One of the tricks I applied when creating .NET applications was introducing a GlobalAssemblyInfo.cs file.

This class contained all the shared assembly information and was referenced in the AssemblyInfo.cs file of all my projects. It allowed me to update the general settings like AssemblyVersion in one place.

However in .NET Core/.NET Standard, the AssemblyVersion.cs file no longer exists.Instead you can specify these settings using the Package tab of your project settings.

But what if you want to still share some settings among your projects?

You can still do this by adding a shared project file:

  • Step 1 – Add a solution folder to your solution.
  • Step 2 – Right click on the solution folder, choose Add –> New Item –> Text File. Rename the text file to GlobalAssemblyInfo.proj.
  • Step 3 -  Open the proj file and add the settings you want:
  • Step 4 – Add the settings to your other projects. For each project, right click on your project, choose Edit ProjectName.csproj.
  • Step 5 -  Add the following line to the csproj files:

No comments: