I recently added some copyright information to a set of C# projects (dlls) via the Properties->Application->Assembly Information button. I have several such projects in a single solution. Upon compilation I get error message of the type:
error CS0579: Duplicate 'XXX' attribute
where 'XXX' is the name of one of the attributes I specified (e.g. AssemblyFileVersionAttribute)
Googling I found that in the case of a class that is derived from the Attribute class, duplicates can be permitted by use of:
[System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=true)]
class NewAttribute : System.Attribute { }
But in my case, I have added these attributes via the properties dialog and have statements (in AssemblyInfo.cs for each project) such as:
[assembly: AssemblyCompanyAttribute("My Company")]
[assembly: AssemblyProductAttribute("My Product")]
[assembly: AssemblyCopyrightAttribute("© 2012 My Company, All Rights Reserved.")]
[assembly: AssemblyVersionAttribute("13.0.0.0")]
[assembly: AssemblyFileVersionAttribute("1.0.0.0")]
and do not have any manually derived attribute classes I can attach any qualifiers to.
How do I solve this duplicate issue?
By adding this in .csproj file solved the issue
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
</PropertyGroup>
As Bob suggested, if you don't want to add them individually, you can add
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
to the <PropertyGroup>
.
I think you already specified those attributes in Assembly Information window of Project Properties. If you did this, remove those attributes from the Assembly Information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With