'Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute
I am trying to dive into the ASP.NET Core. So, I decided to try create a pet project, using the VS Code.
With the help of the dotnet cmd I created a solution, added projects into it (App, Tests, EF, Mapping, etc.) and setup references between the projects.
But now when I try to run the solution I am getting the Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute error and a bunch of other strange errors. Here is a piece of the errors I am getting:
c:\Projects\dotNet\BestTongue\Utilities\objBinRemove\obj\Debug\netcoreapp3.0\objBinRemove.AssemblyInfo.cs(10,12): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [C:\Projects\dotNet\BestTongue\BestTongue.csproj]
c:\Projects\dotNet\BestTongue\Utilities\objBinRemove\obj\Debug\netcoreapp3.0\objBinRemove.AssemblyInfo.cs(11,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [C:\Projects\dotNet\BestTongue\BestTongue.csproj]
...
I am not sure what else do I need to add to my question to make the problem solvable. So, please, ask all the necessary details in comments if I missed something.
I spent a lot of time trying to find a solution to the issue, but in vain.
UPDATE
As was recommended in the comments section I tried to use the solutions mentioned in the related question.
I tried to add the:
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
So, now my .csproj looks like that:
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\App\App.csproj" />
<ProjectReference Include="..\Data\Data.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>netstandard3.0</TargetFramework>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
</PropertyGroup>
</Project>
But I still see the same errors:
Also, I wrote a script which goes over all the projects and removes the *.AssemblyInfo.cs. After that I checked whether or not building project will bring the *.AssemblyInfo.cs back. And *.AssemblyInfo.cs does appear after the build again. Also, now (after the .csproj file modification) I got a new error:
C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(140,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Standard 3.0. Either target .NET Standard 2.1 or lower, or use a version of the .NET SDK that supports .NET Standard 3.0. [C:\Projects\dotNet\BestTongue\Controllers\Controllers.csproj] C:\Program
Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(140,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Standard 3.0. Either target .NET Standard 2.1 or lower, or use a version of the .NET SDK that supports .NET Standard 3.0. [C:\Projects\dotNet\BestTongue\App\App.csproj]
It may be useful for someone who is trying to help me to check the solution locally. Here is the solution repository with the latest changes.
Solution 1:[1]
This was spot on (Ian Kemp nos 1 above.) I was upgrading .net app to .net core 5, painful effort to rid this issue. Now all good. Do a file search on your .net core app (I assume 3.X is the same) and remove all the AssemblyInfo.cs files (.net core builds AssembleyInfo from the project file so doesn't matter if you delete these as well. Recompile and the problem should go away. One extra, make sure your Library (DLL) files are all 'Library' in the Property group... e.g.
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net5.0</TargetFramework>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
Solution 2:[2]
I solved this by re-structuring my solution rather than deleting files or changing any settings.
My original structure looked like this, note how all projects were inside the solution folder:
Solution folder
- Website project
- Business project
- Repository project
- Database project
I re-structured it to look like this and now I no longer have the duplicate attribute errors:
Solution folder
- Website project
Business folder
- Business project
Repository folder
- Repository project
Database folder
- Database project
Solution 3:[3]
I experienced this issue when we moved the projects to a new folder (in this case one level higher), but our repo still had the projects in their old locations as well, so it found the duplicate. My key was to clear out the old projects (this was Jenkins so I wiped the workspace) and rebuild.
Solution 4:[4]
Solved the Error CS0579 - error because of class library reference (dotnet5.0)
Error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute (CS0579)
Error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute (CS0579)
If you get this error, it's because it create the files twice once in the class library and once in the referenced project. Go in the referenced project to: “NameOfTheClassLibrary” —> obj —> Debug —> net5.0 —> ref —> here delete the files that are mentioned in the error stack (for me: AssemblyInfo.cs & .NETCore...AssemblyAttributes.cs)
(Visual Studio access ClassLibrary.csproj file): Open the ClassLibrary.csproj —> by right clicking —> unload —> right click again —> tool —> Edit file
Add TargetFramework, GenerateAssemblyInfo, GenerateTargetFrameworkAttribute to the file to prevent the compiler from creating this files in the referenced project.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net5.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>
</Project>
Save the file a recompile.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | John Irvine |
| Solution 2 | |
| Solution 3 | Mike |
| Solution 4 | Basil Jung |



