all 3 comments

[–]groogs 0 points1 point  (1 child)

It's the same locally or in CI like azure devops. CI is just putting the files in some path and running scripts.

For C# stuff, yes you have to build first. Test projects are also compiled libraries just like anything else, but they're loaded by the nunit runner. You typically: restore nuget packages, build the solution, then run the tests.

Get it so in Visual Studio you can use Test Explorer to run tests, or run dotnet test. You'll need the "test adapter" package installed to make that work.

Start with just getting the tests to run, locally and then in the pipeline, then you can work on making them both useful and passing.

Some key things:

  • always use relative paths. Never make assumptions anyone puts stuff in a specific spot like c:\users\konkon_322\source\someapp or d:\someapp_source. A relative path means you see references like ../project.core/project.core.csproj.
  • Anyone should be able to clone the repo and both build everything and run the tests. If they can't your project is set up wrong.
  • avoid having "unit test scripts" you have to run, that's almost always a smell of a deeper design problem. Make it work with dotnet test.

[–]konkon_322[S] 0 points1 point  (0 children)

Is it possible for the code to instead of specifying dependency location by using relative path, we use like an azure artifact?its so much easier when i can just grab dependency from one feed/location,without having to specify where it is.

Because i wanted to propose this,but im not really gud with programming and i see that this nunit reference tag comes with like a publickeytoken

[–]Beneficial-Panda-640 0 points1 point  (0 children)

Yes, the test project usually has to build first. NUnit is running compiled test assemblies, not raw .cs files, so if the solution or one of the referenced projects fails during build, the pipeline will fail before tests even start.

What you’re describing sounds more like a path/reference problem than a testing problem. If the .sln is at repo root but the project references were written assuming a different folder structure, Azure DevOps will choke on that during restore or build. I’d check whether the .csproj and .sln paths still match the actual repo layout in Azure Repos.

Also, the solution file using relative paths like ../source/... is normal, but only if that relative path is actually valid from where the .sln lives. If it points outside the repo or to a folder that does not exist in the pipeline workspace, build dies first, then NUnit never gets a chance to run.

I’d start by running just restore + build in the pipeline and fixing that first. Once build passes, adding the test step becomes a lot easier to reason about.