NuGet 包:我们是否需要将它们添加到引用项目和被引用项目中?

发布于 2025-01-11 04:08:54 字数 612 浏览 0 评论 0原文

这听起来可能微不足道,但我仍在尝试了解这里发生的事情。

我的 VSTO 加载项包含以下项目(VS2022、.NET Framework 4.8):

  1. Addin(VSTO 加载项,参考文献 #2)
  2. View(WPF 控件库,参考文献 #3)
  3. VM(类库,参考文献 #4)
  4. DataAccess (类库,引用 RestSharp nuget 包)

当我构建项目时,#4 将其 DLL 以及 RestSharp DLL 复制到其输出文件夹。随后,#3 将其自己的 DLL 以及来自 #4 的两个 DLL 复制到其输出。但#2 不会将 RestSharp DLL 复制到其输出,仅复制 View、VM 和 DataAccess DLL。 #1 也遵循该套件并忽略 RestSharp DLL。

为什么?这与数据访问针对 .NET Standard 2.0(与针对 .NET Framework 4.8 的其他层不同)这一事实有什么关系吗?

我已经通过将 RestSharp 的 NuGet 引用添加到项目 #2 来解决这个问题,但对我来说这感觉像是一个 hack。我只是想了解 Visual Studio 或 MSBuild 如何决定是否包含引用项目的依赖项。

This may sound trivial, but I'm still trying to understand what's going on here.

My VSTO add-in contains the following projects (VS2022, .NET Framework 4.8):

  1. Addin (VSTO add-in, references #2)
  2. View (WPF control library, references #3)
  3. VM (Class library, references #4)
  4. DataAccess (Class library, references RestSharp nuget package)

When I build the project, #4 copies its DLL as well as RestSharp DLL to its output folder. Thereupon #3 copies its own DLL as well as the two DLLs coming from #4 to its output. But #2 does not copy RestSharp DLL to its output, only View, VM and DataAccess DLLs. #1 also follows the suite and ignores RestSharp DLL.

Why? Has this got anything to do with the fact that Data Access is targeting .NET Standard 2.0, unlike other layers which are targeting .NET Framework 4.8?

I have fixed the problem by adding RestSharp's NuGet reference to project #2 as well, but it feels like a hack to me. I'm just trying to understand how Visual Studio or MSBuild decides whether or not to include dependencies of referenced projects.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怎樣才叫好 2025-01-18 04:08:54

我正在努力解决同样的问题,我遇到了这个

我想你就在这里:

为什么?这与数据访问针对 .NET Standard 2.0(与针对 .NET Framework 4.8 的其他层不同)这一事实有什么关系吗?

现在我将实施你的黑客解决方案。

I was struggling with the same problem and I came across this.

I think you were right here:

Why? Has this got anything to do with the fact that Data Access is targeting .NET Standard 2.0, unlike other layers which are targeting .NET Framework 4.8?

For now I will be implementing your hack solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文