未复制引用的项目依赖项 DLL [英] Referenced project dependencies DLL are not being copied
问题描述
我的项目解决方案目前有三个项目:
My project solution is currently having three projects:
- MyProject,这是我的主要启动项目(使用
.NET Framework 4.7
)- WPF,UI 规范, - MyProject.Core - 类库 (
.NET Standard 2.0
) - 保存模型和所有幕后"数据 - MyProject.Relational - 类库 (
.NET Standard 2.0
) - 负责处理和保存数据库特定信息
- MyProject, which is my main startup project (using
.NET Framework 4.7
) - WPF, UI specfic, - MyProject.Core - class library (
.NET Standard 2.0
) - holding the models, and all of the 'behind the scenes' data - MyProject.Relational - class library (
.NET Standard 2.0
) - responsible for processing and saving the database specific informations
Project 1
(main) 已经设置了对项目 2
和 3
的引用.
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.
我尝试了什么:
- 清理项目,删除 bin/obj 目录,
- 设置项目引用属性设置
copy local
为True
, - 此问题中给出的解决方案:引用的 DLL 未复制到引用项目
使用 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屋!