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.

error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute

See original GitHub issue

Hello, I am working on a SDK where we have multiple build targets. I have been running into an issue where each of the targets seems to be building assembly attributes when I have explicitly turned them off with

<TargetFramework>netstandard2.0</TargetFramework> <GeneratePackageOnBuild>true</GeneratePackageOnBuild> <AssemblyName>Dropbox.Api</AssemblyName> <RootNamespace>Dropbox.Api</RootNamespace> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>

In the main property group of every csproj file

Here is the errors I am seeing:

net45obj\Debug\.NETFramework,Version=v4.5.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtime. Versioning.TargetFrameworkAttribute' attribute [dropbox-sdk-dotnet\dropbox-sdk-dotnet\Dropbox.Api\ Dropbox.Api.NetStandard.csproj] net45obj\Release\.NETFramework,Version=v4.5.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtim e.Versioning.TargetFrameworkAttribute' attribute [dropbox-sdk-dotnet\dropbox-sdk-dotnet\Dropbox.Ap i\Dropbox.Api.NetStandard.csproj] portable40obj\Debug\.NETPortable,Version=v4.0,Profile=Profile344.AssemblyAttributes.cs(4,12): error CS0579: Duplicate ' global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [dropbox-sdk-dotnet\dropbox- sdk-dotnet\Dropbox.Api\Dropbox.Api.NetStandard.csproj] portable40obj\Release\.NETPortable,Version=v4.0,Profile=Profile344.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [dropbox-sdk-dotnet\dropbo x-sdk-dotnet\Dropbox.Api\Dropbox.Api.NetStandard.csproj] portableobj\Debug\.NETPortable,Version=v4.5,Profile=Profile111.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'gl obal::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [dropbox-sdk-dotnet\dropbox-sd k-dotnet\Dropbox.Api\Dropbox.Api.NetStandard.csproj] portableobj\Release\.NETPortable,Version=v4.5,Profile=Profile111.AssemblyAttributes.cs(4,12): error CS0579: Duplicate ' global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [dropbox-sdk-dotnet\dropbox- sdk-dotnet\Dropbox.Api\Dropbox.Api.NetStandard.csproj] obj\Release\netstandard2.0\.NETStandard,Version=v2.0.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::Syst em.Runtime.Versioning.TargetFrameworkAttribute' attribute [dropbox-sdk-dotnet\dropbox-sdk-dotnet\D ropbox.Api\Dropbox.Api.NetStandard.csproj]

I am not sure if I am generating this incorrectly or if there is another way to disable this error.
For more information, I am working on the Dropbox SDK

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
CreepyGnomecommented, Feb 22, 2021

This exact issue just started occurring for me this morning, just on my box. Our CICD is fine and asked around and no one else is having this issue on their local boxes. I tried a full clean and still occurs. If I add the below to the problem csproj files it goes away. However I should not need to have this, and I cannot check them in as no one else I can find has this issue. It seem related to .NET 5.

I am using .NET 5.0.102 and I tried it in an IDE and via dotnet CLI and get the same issue. With no changes to our CSproj files in like 2 months not sure how everything was fine on Friday and then Monday morning this is now happening.

The below additions to a CSProj files makes the errors go away and allows me to make progress on other things, but is a horrible experience as I have to ensure I don’t check them in and I have to undo the changes many time and restore them either manually or via a stash depending on the situation.

<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

I have done a full clean and it didn’t address the issue. I even manually deleted all the bin and obj folders and still occurs on a build.

FINAL SOLUTION

What I had to do to finally get this error to go away without changing the CSproj files was to delete the directory and re-clone the repository and then it went away.

So .NET went screwy it seems and did something similar to what @joeloff mentioned above that requires basically delete and re-clone for some reason to resolve.

2reactions
pikaduncommented, Jul 18, 2020

I also encountered the same problem.

I created a console project with dotnet cli. After run command dotnet build, I got an error that Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute in ~/obj/Debug/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs:

// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]

It duplicate with project file .csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

</Project>

OS Version: Windows 10 Linux Subsystem, BUILD: 19041, RELEASE: Ubuntu 20.04 LTS DOTNET Version: 5.0.100-preview.6.20318.15

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error CS0579 Duplicate 'global::System.Runtime. ...
I can work around the issue by commenting out the contents of the file, but not by deleting the file.
Read more >
Error - CS0579 Duplicate '<type>Attribute'
On a recent project I got the "CS0579 Duplicate 'global::System.Runtime.Versioning. Attribute" error when I tried to build more project.
Read more >
Error CS0579 Duplicate 'global::System.Runtime. ...
Error CS0579 Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute MyUIApp D:\MyUIApp\obj\Debug\netcoreapp3.1\.NETCoreApp,Version=v3.
Read more >
Duplicate 'global::System.Runtime.Versioning. ...
AssemblyAttributes.cs(4,12,4,70): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute ...
Read more >
Diagnostic issue - Error CS0579 Duplicate 'global::System. ...
Runtime.Versioning.TargetFrameworkAttribute'. I have an error which is: Error CS0579 Duplicate 'global::System.Runtime.
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