简体   繁体   English

引用的项目依赖项DLL不被复制

[英]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, MyProject ,这是我的主要启动项目(使用.NET Framework 4.7 )-WPF,特定于用户界面,
  2. MyProject.Core - class library ( .NET Standard 2.0 ) - holding the models, and all of the 'behind the scenes' data MyProject.Core类库( .NET Standard 2.0 )-保存模型以及所有“幕后”数据
  3. MyProject.Relational - class library ( .NET Standard 2.0 ) - responsible for processing and saving the database specific informations MyProject.Relational类库( .NET Standard 2.0 )-负责处理和保存数据库特定的信息

Project 1 (main) has set a reference to project 2 and 3 . 项目1 (主要)已为项目23设置了引用。

For the project 3 I have installed a NuGet dependency of Microsoft.EntityFrameworkCore.Sqlite (2.0.3) . 对于项目3我已经安装了Microsoft.EntityFrameworkCore.Sqlite (2.0.3)NuGet依赖项。

Now, when I finally want to make use of project 3 and call it's method, the following exception is being thrown: 现在,当我最终想要使用项目3并调用它的方法时,将引发以下异常:

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. 当然,这是缺少的DLL文件-没有实体框架DLL被复制到应用程序的Debug目录中。

Why is that ? 为什么会这样呢? Is this intended behaviour? 这是预期的行为吗? Do I have to install the dependency of Microsoft.EntityFrameworkCore.Sqlite for project 1 as well? 我也必须为项目1安装Microsoft.EntityFrameworkCore.Sqlite的依赖项吗? Pretty pointless to me, referencing the same dependency to project that is making no use of it. 对于我而言,毫无意义,因为它引用了没有使用它的项目依赖项。

What have I tried: 我尝试了什么:

Using Visual Studio 2017. 使用Visual Studio 2017。

Solved this by adding the following line into my .csproj file: 通过.csproj下行添加到我的.csproj文件中来解决此问题:

<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

Specifically to the PropertyGroup group. 专门针对PropertyGroup组。

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. 我将添加到此答案的任何其他信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM