AssemblyInfo.cs is useful, but it's not necessary.
In .NetCore you can manage AssemblyInfo from the .csproj
file instead of AssemblyInfo.cs
file. The AssemblyInfo.cs
file will be autogenerated in obj folder for you. All you need to do is to set its properties in the csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>myAppName</AssemblyName>
</PropertyGroup>
</Project>
The compiler will complain about duplicate properties if there is an AssemblyInfo.cs
file present in your project with any properties set. In this case you should set GenerateAssemblyInfo
to false (so that it doesn't auto-generate an x.AssemblyInfo.cs
into obj folder):
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyName>myAppName</AssemblyName>
</PropertyGroup>
</Project>
You can choose to handle the assembly information manually (through AssemblyInfo.cs
files instead of through .csproj
file) just by setting auto-generate attributes to false. For example you may set GenerateAssemblyInfo
to false to prevent auto-generation of the AssemblyInfo.cs
or you may set GenerateAssemblyTitleAttribute
to false to prevent auto-generation of Title
attribute inside AssemblyInfo.cs
. This means you can set the assembly information in both AssemblyInfo and csproj. This comes in handy when you want to share a common set of information between different projects, while being able to change some info in each of them. (You can't set a property twice though, but still this is a useful feature)
Just a side note: Since you've migrated to .NetCore you might as well want to migrate your csproj into Project SDK format, if you haven't already done it. Then you will notice a lot of clutter disappearing from csproj making it more readable and easier to maintain, putting more focus on those mentioned properties.
There is a way to do the same thing in Classic .Net Applications: https://github.com/dasMulli/AssemblyInfoGenerationSdk