Resolving Build Error CS0579 Duplicate 'System.Reflection.Assemblyxxxx' attribute
Asked Answered
U

2

7

While using xunit for testing, I'm constantly getting build errors when running the tests (CS0579 and CS0006):

Build Errors generated by Visual Studio when executing tests.

I have tried removing bin/obj folders and tried suppressing the generation of the attribute with <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> but both were causing other issues (source: https://github.com/dotnet/cli/issues/4710).

Soluction structure:

Project structure

I had to manually add references to xunit.core.dll and xunit.assert.dll.

Does anyone have any experience in resolving this issue? I'm additionally having problems testing methods that throw exceptions (see Exception not being thrown in setter) and I suspect this might be a symptom of the root cause.

Ulysses answered 11/3, 2018 at 18:24 Comment(3)
Please ask a question!Excogitate
@OrryVandermeule Apologies, I've edited the question.Ulysses
i have this problem tooVillalpando
T
3

This happened to me when I opened some old code and it wouldn't compile anymore.

The problem was that I had a .csproj project file in a subdirectory of another .csproj project file. (I have no idea how or why I did that 🤷‍♂️). It was:

---- .sln and .csproj 1
  |- .csproj 2

I fixed it by changing the directory structure of the solution to have both projects sitting in their own subdirectory of the .sln file, and to edit the .sln file to reflect the new directory structure.

---- .sln
  | - .csproj 1
  | - .csproj 2
Thrombin answered 8/1 at 6:26 Comment(1)
I had the same problem/compiler error, and found there was a problem with projects and solutionsSlash
A
2

I have my bin and obj folder red dotted, I just simply excluded them from solution, then the issue solved.

Armes answered 13/11, 2023 at 7:39 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Searby

© 2022 - 2024 — McMap. All rights reserved.