C
C#6mo ago
m1dnight

Test project in project where project is in same folder as solution (codecrafters.io)

I am going through codecrafters.io DNS server with C#. The barebones project you get looks like this:
.
├── README.md
├── codecrafters-dns-server.csproj
├── codecrafters-dns-server.sln
├── codecrafters.yml
├── src
│   └── Server.cs
└── your_server.sh
.
├── README.md
├── codecrafters-dns-server.csproj
├── codecrafters-dns-server.sln
├── codecrafters.yml
├── src
│   └── Server.cs
└── your_server.sh
I want to add a unit test solution to this project, but I can't manage to get it working. From what I can tell, codecrafters really wants their project to keep this structure. I'm using Rider and tried adding new project to the solution, but then I get the following error:
CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute
CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute
I attempted to fix this by adding the following to the .csproj file.
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
Is there a way to create a unit test project that does not mess with the codecrafters repository?
1 Reply
m1dnight
m1dnightOP6mo ago
You cannot reference a project from another solution, so I take it that I have to add the test project to the same solution. So back to square 1 I guess? 🙂 Oh, I added a Test file and then just run it from the same project, that works too!
Want results from more Discord servers?
Add your server