Thomas
Thomas

Reputation: 2984

Referenced Copylocal dll from other project in same solution not copied into output folder

I have a solution with 3 projects inside (1 GUI, 1 BLL, 1 DAL). The dal and bll both reference EntityFramework and EntityFramework.SqlServer with copylocal set to true (BLL also references DAL with copylocal true).

The GUI references the BLL and the DAL with copylocal true.

Now the build process works quite fine when I set the GUI as start project. The debug folder then has all the necessary files and dlls inside except the EntityFramework.SqlServer.

I checked a few times if both EntityFramework and EntityFramework.SqlServer have everywhere the same settings,... which they have. I tried to copy it manually to the GUI debug folder and then clear project.....the file remained which indicated that visual studio thinks that the file is not part of the build process.

Thus my question here is twofold:

  1. What can be causing this phenomenon?
  2. What can I do against this?

Upvotes: 1

Views: 291

Answers (1)

Hans Passant
Hans Passant

Reputation: 942257

The starting problem is that you have an indirect dependency on the EntityFramework. MSBuild cannot discover from your EXE project that these assemblies are needed. It can however indirectly discover it from your references to the BLL and DAL project.

But it doesn't just blindly copy everything that is present in the bin\Debug folder of those projects. It looks at the metadata of your BLL.dll and DAL.dll files, they contain the references to the assemblies they need to get the job done. Something you can see when you use ildasm.exe on those DLLs. Double-click the manifest to have a look-see, note the .assembly directives you see there. You'll see:

.assembly extern EntityFramework
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
  .ver 6:0:0:0
}

But note that you don't see an .assembly directive for EntityFramework.SqlServer.

That's where the buck stops, MSBuild simply can't discover that this assembly is required. Or to put it another way, EntityFramework.SqlServer.dll acts like a plug-in. There are different plug-ins for different database engines. There are a bunch of them, you can find them back in the Nuget list.

So you have to copy it yourself.

Upvotes: 1

Related Questions