Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET CORE build results in Duplicate Errors in vscode

I am just trying to understand the whole build/publish topic for .NET Core and was playing around with one basic console application.

When I build the app

dotnet build

and afterwards build it with release configuration

dotnet build --configuration Release

I receive errors saying

Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [test]

obviously the files

./obj/Debug/netcoreapp2.1/test.Assembly.info

and

./obj/Release/netcoreapp2.1/test.Assembly.info

store values for the same attributes:

enter image description here

What am I doing wrong?

Some further questions to get a clearer picture of this:

  • As a DEV, would I delete all Debug stuff before building for release?
  • What is the behind-the-scences difference between building for debug or release?
  • Why should I ever publish for (default) debug configuration (dotnet publish)?

I've read all the documentation from ms but imo its from and for people more familiar with building processes.

Thank you very much in advance

like image 968
TGY Avatar asked Apr 16 '19 13:04

TGY


1 Answers

In short, setting GenerateAssemblyInfo to false in the relevant .csproj should do the trick:

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

See this git-issue

And this one

Short explanation: .NET CORE first introduced the project.json based project system, which replaced AssemblyInfo.cs. Later, project.json was dropped in favor of a more extensive .csproj usage. Read more here

like image 155
NotImplementedException Avatar answered Nov 16 '22 01:11

NotImplementedException