Equivalent to AssemblyInfo in dotnet core/csproj

hultqvist picture hultqvist · Feb 9, 2017 · Viewed 106.8k times · Source

Since dotnet core moved back to the .csproj format, there is a new autogenerated MyProject.AssemblyInfo.cs which contains, among others:

[assembly: AssemblyCompany("MyProject")]
[assembly: AssemblyVersion("1.0.0.0")]

Note that this is automatically regenerated every build. Previously, the file was found in the /obj/ directory, now it appears to be only in memory as the file can't be found on disk and clicking the error message does not open any file.

This is the error message: enter image description here

Since they are defined there, I can't define them myself in the classical AssemblyInfo.cs.

Where/how can I define the Company and Version of a project?

Answer

natemcmaster picture natemcmaster · Feb 12, 2017

As you've already noticed, you can control most of these settings in .csproj.

If you'd rather keep these in AssemblyInfo.cs, you can turn off auto-generated assembly attributes.

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

If you want to see what's going on under the hood, checkout Microsoft.NET.GenerateAssemblyInfo.targets inside of Microsoft.NET.Sdk.