error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute
See original GitHub issueHello, 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:
- Created 3 years ago
- Reactions:4
- Comments:7 (2 by maintainers)
Top GitHub Comments
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.
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.
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
:It duplicate with project file
.csproj
OS Version: Windows 10 Linux Subsystem, BUILD: 19041, RELEASE: Ubuntu 20.04 LTS DOTNET Version: 5.0.100-preview.6.20318.15