question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet build results in error CS0579 duplicate attributes with AssemblyVersionAttribute (and others) specified

See original GitHub issue

Building a library project fails with error CS0579 (duplicate attribute) with library projects with AssemblyVersionAttribute (or other assembly attributes) specified.

  • Adding (for example) <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> to csproj fixes

Steps to reproduce

  • dotnet new -t lib
  • insert [assembly: System.Reflection.AssemblyVersion("0.1.0.0")] into Library.cs
  • dotnet restore
  • dotnet build

Expected behavior

Build is successful

Actual behavior

Build fails:

   "C:\dsedev\src\AssemblyInfoTest\AssemblyInfoTest.csproj" (Build target) (1) ->
   (CoreCompile target) ->
     obj\Debug\netstandard1.4\AssemblyInfoTest.AssemblyInfo.cs(13,12): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute [C:\dsedev\src\AssemblyInfoTest\AssemblyInfoTest.csproj]

Environment data

C:\dsedev\src\AssemblyInfoTest>dotnet --info
.NET Command Line Tools (1.0.0-preview3-004056)

Product Information:
 Version:            1.0.0-preview3-004056
 Commit SHA-1 hash:  ccc4968bc3

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

54reactions
frankbuckleycommented, Nov 19, 2016

Setting GenerateAssemblyInfo property to false fixes for all attributes:

<PropertyGroup>
  <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
5reactions
alexelliscommented, Aug 16, 2017

This is a very odd error and unexpected - I got it by creating a new “console” type of project, a “library” type and then referencing the library from the console app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet build results in error CS0579 duplicate attributes ...
Building a library project fails with error CS0579 (duplicate attribute) with library projects with AssemblyVersionAttribute (or other ...
Read more >
VS 2017 Build Errors - Duplicate Attributes in AssemblyInfo ...
This happens because the new .NET tools automatically create the attributes and add them to the assembly, so they now appear twice in...
Read more >
CS0579 Duplicate Attribute Error with .NET Core
The error is a result of the build process generating AssemblyInfo.cs files in each project obj directory. This file exists to provide MSBuild ......
Read more >
Dealing with Duplicate Assembly Attributes in .Net Core
Severity Code Description Project File Line Suppression State Error CS0579 Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute ...
Read more >
Converting a simple solution/project to .NET Core
Trying the same (dotnet new classlib) on the test project produces slightly more mixed results... the same assembly attribute errors but then a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found