'vs 2015 Error CS0006 Metadata file .dll' could not be found

I am trying to add two new test projects to my solution. When I add them and add references, the build initially creates the dll's in the debug folder. when I build or rebuild again, it is always empty and I have a Error CS0006 Metadata file .dll' could not be found error. I've checked the build configuration manager and the boxes are checked to have it output to the debug folder. I've tried clean, build, rebuild on the solution, I've made sure there were no other left-over projects laying around and deleted them. I'm not sure what else I can do to get it to build and output the dll's..



Solution 1:[1]

I fixed this by adding the target project as a dependency.

Right-click on the Solution in Solution Explorer, select Project Dependencies, choose a test project, and select the project from which the dll is built.

Solution 2:[2]

I had similar issue. Problem started when I canceled compilation manually.

To solve it, I started compiling projects one by one. Reading output of compilation allowed to spot the root project that was not compiled. That root project had an error. And somehow that error was not reported, looks like due to canceling compilation manually.

I went to that root project, fixed the error. Compiled it only that project. Then compiled the whole solution. And it got fixed.

Solution 3:[3]

I got the same error message.

I referenced core class library (netcore) to core (xproj) application.

Problem was, that I had changed by manual editing in the xproj project, the output path:

to

<OutputPath Condition="'$(OutputPath)'=='' ">..\bin\</OutputPath>

but my xproj application had:

<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>

Changing to the same output path helped.

Solution 4:[4]

Check if the .nuget directory is complete.

File names:

-NuGet.Config
-NuGet.exe
-NuGet.targets
-packages.config

In my case NuGet.exe was missing from the branch, because when I check in on TFS, it does not send NuGet.exe.

Solution 5:[5]

I got a similar error. It turned out to be an issue with the database migrations. Unfortunately, I could not fix the issue.

My solution was to delete the migrations and the DB. When I added migrations again, everything was working. It should be possible to delete the migrations from the Db as well as from the .net migrations folder and then treat the project as database first. There is likely a better solution though, and I don't know that I would try the above with real data at stake.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael Mainer
Solution 2 user
Solution 3
Solution 4 techdreams
Solution 5 SakerCobalt