引用的项目依赖项DLL不被复制 [英] Referenced project dependencies DLL are not being copied

查看:483
本文介绍了引用的项目依赖项DLL不被复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目解决方案当前有三个项目:

My project solution is currently having three projects:


  1. MyProject ,这是我的主要启动项目(使用 .NET Framework 4.7 )-WPF,UI特定,

  2. MyProject.Core -类库( .NET Standard 2.0 )-保存模型以及所有幕后数据

  3. MyProject.Relational -类库( .NET Standard 2.0 )-负责处理和保存数据库的特定信息

  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

项目 1 (主要)已设置对项目 2 和<$的引用c $ c> 3 。

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

对于项目 3 我已经安装了< Microsoft.EntityFrameworkCore.Sqlite(2.0.3)的code> NuGet 依赖项。

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

现在,当我最终要使用项目 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.

这当然是丢失的DLL文件-没有实体框架DLL被复制到应用程序 Debug 目录。

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

为什么?这是预期的行为吗?我是否还必须为项目 1 安装 Microsoft.EntityFrameworkCore.Sqlite 的依赖项?对于我而言,毫无意义,因为它引用了没有使用它的项目依赖项。

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.

我尝试过什么:

  • 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

使用Visual Studio 2017。

Using Visual Studio 2017.

推荐答案

通过在我的 .csproj 文件中添加以下行来解决此问题:

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

<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

专门用于 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.

这篇关于引用的项目依赖项DLL不被复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆