Closed NicolasReyDotNet closed 4 years ago
Well the problem is solved, the problem was because, I guess, the Test project was inside the main project.
Now I have a folder structure like this
MyProject
src/MyProject.csproj
tests/MyTestProject.csproj
If you are like me and changing the project structure is not realistic you can use a combination of this:
https://helloglenn.me/blog/dotnet-clean-bin-obj/
<Target Name="SpicNSpan" AfterTargets="Test">
<RemoveDir Directories="$(BaseOutputPath)" />
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
</Target>
I included it in both my normal csproj and test csproj to be safe
dotnet test result an error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute'
Hi, When building my project under Azure Devops yaml pipeline, if I launch unit test in my Dockerfile, I get the following : error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute'
General
The project is like organised this way
So my Unit test (xUnit) project is under tests folder of my main project within the same repository.
My Dockerfile used for my CICD is
I both ITF.Microservices.Ordering.csproj and ITF.Microservices.Ordering.UnitTests.csproj I added the following to get rid of Duplicate errors.
Under Azure Devops I use the following pipeline
And the following build_deploy.yml template
The pipeline does build and publish the release correctly, but when I require dotnet test instruction from the Dockerfile, the tests are played and published
But it ended with an error
Full error line here obj/Release/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [/src/src/ITF.Microservices.Ordering/ITF.Microservices.Ordering.csproj]
When I remove the dotnet test from the Dockerfile instruction, everything works fine
Some people seem to face the same problem as me https://stackoverflow.com/a/62021598/4734707