Getting a "could not be found" from the unit test project

Rod At Work 866 Reputation points
2022-05-25T17:34:20.98+00:00

I've made some changes to a ASP.NET MVC Core (.NET 6) solution. There's two projects; the MVC project and a xUnit test. Suddenly today, I started to get this error:

CS0006 Metadata file 'C:\Repos\PW\PharmacyWarehouseV2\PharmacyWarehouseV2\obj\Debug\net6.0\ref\PharmacyWarehouseV2.dll' could not be found PharmacyWarehouseV2.Test

So, it is coming from the xUnit project PharmacyWarehouseV2.Test. And it's trying to find a DLL which the build is supposed to create. So, how do I get around MSBuild complaining about what it should be creating?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,169 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 48,581 Reputation points
    2022-05-25T20:26:58.06+00:00

    Generally you get this when the previous project fails to build. Try a clean build. Also ensure that you're using a project reference to the other project and not a binary reference. There is also the chance that it is related to using different target frameworks but you'd have to identify what changed between the working and non-working versions.