本文介绍了如何添加 NuGet 仅源包依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个框架,用于 Microsoft 的 CRM/XRM/CDS/PowerPlatform/DataVerse 插件.这些插件不能包含对外部非 .Net 框架非 MicrosoftSDK dll 的任何依赖.我没有使用 ILMerging 依赖项,而是使用了 NuGet 的 Source Only Packages,它允许通过 NuGet 共享源文件本身,从而无需引用和 ILMerging 其他 dll.

I have a framework that I've created to be used with Microsoft's CRM/XRM/CDS/PowerPlatform/DataVerse plugins. These plugins can not contain any dependencies on external non-.Net Framwork non-MicrosoftSDK dlls. Rather than ILMerging dependencies I've made use of NuGet's Source Only Packages that allow the source files themselves to be shared via NuGet, removing the need for referencing and ILMerging other dlls.

我正在尝试使这些 NuGet 包与 dotnetcore 兼容.有两个 nuget 包 DLaB.Xrm.Source 和 DLaB.Common.Source.DLaB.Xrm.Source 取决于 DLaB.Common.Source.我能够为 dotnetcore 的 Common 包成功更新 Nuget 包,一切看起来都很棒.然后我更新了 dotnetcore 的 Xrm 包,但是当我测试只安装 DLaB.Xrm.Source 包时,它似乎没有添加 DLaB.Common.Source 包,因为现在我收到了那些缺失的构建错误文件,即使它被列为依赖项:

I'm attempting to make these NuGet Packages dotnetcore compatible. There are two nuget packages DLaB.Xrm.Source and DLaB.Common.Source. DLaB.Xrm.Source depends on DLaB.Common.Source. I was able to successfully update the Nuget Package for the Common package for dotnetcore, and everything looks great. I then updated the Xrm package for dotnetcore, but when I tested installing just the DLaB.Xrm.Source Package, it doesn't appear to have added the DLaB.Common.Source Package, since now I'm getting build errors for those missing files, even though it is listed as a dependency:

我错过了什么吗?有没有一种方法可以让它发挥作用,还是我应该直接将 DLaB.Common.Source 文件包含在 DLaB.Xrm.Source 文件中?

Am I missing something? Is there a methodology to get this to work, or should I punt and just include the DLaB.Common.Source files in the DLaB.Xrm.Source files directly?

这就是我在 NuSpec 文件中列出依赖项的方式:

This is how I have the dependencies listed in my NuSpec file:

<dependencies>
  <group targetFramework="net">
    <dependency id="DLaB.Common.Source" version="1.2.0.10" />
  </group>
  <group targetFramework="netcoreapp">
    <dependency id="DLaB.Common.Source" version="1.2.0.10" />
  </group>
</dependencies>

推荐答案

看起来这是 NuGet 的设计.据此:

Looks like this is by design for NuGet. According to this:

https://docs.microsoft.com/en-us/nuget/reference/nuspec#dependencies-element

内容文件被排除在外,因此我很可能必须在父项中包含依赖项的源文件.

Content files are excluded, so I will most likely have to include the source files of the dependency in the parent.

用于排除:

以逗号分隔的包含/排除标签列表(见下文)表明要在最终包中排除的依赖项.默认值是 build,analyzers 可以被覆盖.但内容/ContentFiles 也隐式排除在最终包中不能被覆盖.使用 exclude 指定的标签优先在包含指定的那些之上.例如,include="runtime,编译"排除=编译"与 include="runtime" 相同.

这篇关于如何添加 NuGet 仅源包依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 05:45