未从引用项目复制的 NuGet 包 [英] NuGet packages not copied from referenced project

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

问题描述

我有一个非常奇怪的错误,我无法解释.

所以我的设置很简单:

我有一个包含 2 个项目的解决方案,我们将它们命名为 ProjectAProjectB.ProjectA 引用了一些 NuGet 包,如果我构建 ProjectA,我可以看到输出目录中的所有程序集,即 bin 文件夹.ProjectB 现在引用 ProjectA,但是如果我构建 ProjectB,我在输出目录中有 ProjectA 程序集,但是不是从 ProjectA 引用的 NuGet 包.

ProjectBProjectA 的引用是通过 References -> Add Reference... -> Solution -> ProjectA 添加的.p>

我还创建了一个涵盖此案例的小测试项目,但它在我的测试项目中运行良好.

有什么想法吗?

解决方案

如果依赖关系图比你描述的更复杂,你可能会遇到一些版本问题.

  1. 将编译器输出设置为诊断以查看发生了什么:VS->Options->Projects and Solutions->Build and Run->MSBuild project build output vervosity:->Diagnostic
  2. 编译解决方案.如果你发现一些类似的问题:<块引用>

    X, Version=2, Culture=neutral, PublicKeyToken=null"和X, Version=1, Culture=neutral, PublicKeyToken=null"之间存在冲突.

    选择X, Version=2, Culture=neutral, PublicKeyToken=null"是因为它是主要的,而X, Version=1, Culture=neutral, PublicKeyToken=null"不是.

  3. 尝试在各处使用相同的依赖版本修复该问题,然后重新编译.

I have a very strange error I have no explanation for.

So my setup is very simple:

I have a solution with 2 projects, let's name them ProjectA and ProjectB. ProjectA references some NuGet packages and if I build ProjectA, I can see all assemblies in the output directory, the bin folder. ProjectB now references ProjectA, but if I build ProjectB, I have the ProjectA assembly in the output directory, but not the NuGet packages referenced from ProjectA.

The reference from ProjectB to ProjectA is added with References -> Add Reference... -> Solution -> ProjectA.

I also created a little test project covering this case, but it works just fine in my test project.

Any ideas?

解决方案

If the dependency graph is more complex than what you described you might have some versioning issues.

  1. Set the compiler output to diagnostics to see what’s happening: VS->Options->Projects and Solutions->Build and Run->MSBuild project build output vervosity:->Diagnostic
  2. Compile the solution. If you find some issue similar to:

    There was a conflict between "X, Version=2, Culture=neutral, PublicKeyToken=null" and "X, Version=1, Culture=neutral, PublicKeyToken=null".

    "X, Version=2, Culture=neutral, PublicKeyToken=null" was chosen because it was primary and "X, Version=1, Culture=neutral, PublicKeyToken=null" was not.

  3. Try fixing that issue using the same dependency version everywhere and compile again.

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

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