.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 
// set of attributes. Change these attribute values to modify the information
// 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:

<PropertyGroup>
....
  <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
....
</PropertyGroup>

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

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

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

  <ItemGroup>
    <Folder Include="Properties\" />
  </ItemGroup>

Azure DevOps / VisualStudio.com hosted version controlling with SourceTree on MacOSX

If you want to access your Git based repository with SourceTree, you need to genereate a Personal Access Token for your account in DevOps. Follow the tutorial above:

https://docs.microsoft.com/hu-hu/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&viewFallbackFrom=vsts&tabs=preview-page

After you have done with setting up PAT, set up SourceTree on Mac:

  1. SourceTree > Preferences
  2. Accounts > Add…

Enter your devops server url. ex: https://AnAwesomeCompany.visualstudio.com/
As username, enter your e-mail address
As password, paste your private access token
Set the protocol to HTTPS.

After the success configuration, you will see your remote repositories on the main screen of Remotes section.