Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referenced project dependencies DLL are not being copied

My project solution is currently having three projects:

  1. MyProject, which is my main startup project (using .NET Framework 4.7) - WPF, UI specfic,
  2. MyProject.Core - class library (.NET Standard 2.0) - holding the models, and all of the 'behind the scenes' data
  3. MyProject.Relational - class library (.NET Standard 2.0) - responsible for processing and saving the database specific informations

Project 1 (main) has set a reference to project 2 and 3.

For the project 3 I have installed a NuGet dependency of Microsoft.EntityFrameworkCore.Sqlite (2.0.3).

Now, when I finally want to make use of project 3 and call it's method, the following exception is being thrown:

System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.

This, of course is a missing DLL file - no entity framework DLL's are being copied to the app Debug directory.

Why is that? Is this intended behaviour? Do I have to install the dependency of Microsoft.EntityFrameworkCore.Sqlite for project 1 as well? Pretty pointless to me, referencing the same dependency to project that is making no use of it.

What have I tried:

  • Cleaning up the project, removing bin/obj directories,
  • Set project reference properties setting copy local to True,
  • Solutions given in this question: Referenced DLL not being copied to referencing project

Using Visual Studio 2017.

like image 232
RA. Avatar asked May 23 '18 06:05

RA.


1 Answers

Solved this by adding the following line into my .csproj file:

<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

Specifically to the PropertyGroup group.

Not sure why it makes such difference, if anyone could explain and post in the comment it would be great. Any additional informations I will add to this answer.

like image 173
RA. Avatar answered Sep 30 '22 14:09

RA.