Search code examples
visual-studiovisual-studio-2017.net-coreassemblyinfo

Equivalent to AssemblyInfo in dotnet core/csproj


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?


Solution

  • 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.