相关文章推荐
孤独的沙发  ·  qt5 - Embed a GTK ...·  1 年前    · 
刀枪不入的斑马  ·  rust ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

DotNet Debugging CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute

Ask Question

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

Did you tried to set GeneratePackageOnBuild to false?

<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>

But first delete all of these assembly attributes files

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.