问题
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.
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:
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?
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>
回答1:
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.
for Exclude:
A comma-delimited list of include/exclude tags (see below) indicating of the dependency to exclude in the final package. The default value is build,analyzers which can be over-written. But content/ ContentFiles are also implicitly excluded in the final package which can't be over-written. Tags specified with exclude take precedence over those specified with include. For example, include="runtime, compile" exclude="compile" is the same as include="runtime".
来源:https://stackoverflow.com/questions/65051835/how-to-add-nuget-source-only-package-dependencies