未从引用项目复制的 NuGet 包

编程入门 行业动态 更新时间:2024-10-26 10:33:32
本文介绍了未从引用项目复制的 NuGet 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

所以我的设置很简单:

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

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

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

有什么想法吗?

解决方案

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

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

    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"不是.

  • 尝试在各处使用相同的依赖版本修复该问题,然后重新编译.
  • 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.

  • 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
  • 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.

  • Try fixing that issue using the same dependency version everywhere and compile again.
  • 更多推荐

    未从引用项目复制的 NuGet 包

    本文发布于:2023-11-07 14:48:22,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1566740.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:项目   NuGet

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!