Referenced project dependencies DLL are not being copied

£可爱£侵袭症+ 提交于 2019-12-12 12:22:25

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/50481249/referenced-project-dependencies-dll-are-not-being-copied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!