Nunit — the type or namespace cannot be found

This was an issue that randomly cropped up one day in a number of my libraries. This sort of error is quite a common one and there can be a number of solutions, in this case my normal routine didn’t work, nor did reinstalling Nunit.

As I use Paket I then tried an older version in case it was that which was causing the issue. Fortunately in Paket this is a ridiculously simple process — just add version <old.version.number> to your paket.dependencies file but that made no difference either.

By sheer luck I decided to try a different library and that one worked! Comparing the tests project files showed a number of differences, the working one was pretty minimal

The ones that didn’t work tended to have more fields completed but taking those out made no apparent difference, then I noticed the tfm’s. The ones that weren’t working all have netcoreapp2.1 as well as those above. Simply removing that resolved the issue.

I’m sure it will come as no suprise to many of you that it turned out that the issue was of course one of my own making. Shortly before it started I had added framework restrictions to my paket.dependencies file

I had incorrectly assumed that netstandard 2.0 would cover netcoreapp2.1. When I explicitly added netcoreapp2.1 to the above it worked as expected.

--

--

Senior Integrations Officer at Doncaster Council Any views expressed are entirely my own.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Steve Ellwood

Senior Integrations Officer at Doncaster Council Any views expressed are entirely my own.