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

查看:27
本文介绍了未复制引用的项目依赖项 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

Project 1 (main) 已经设置了对项目 23 的引用.

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

对于项目 3 我已经安装了 Microsoft.EntityFrameworkCore.Sqlite (2.0.3)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.

我尝试了什么:

使用 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天全站免登陆