我们不能包含引用的项目DLL与三个或以上的项目。
例如,当项目Library1引用项目ReferenceLibrary时,ReferenceLibrary.dll将被添加到Library1的引用。但是,当您引用项目Library1以投影测试应用程序时,只有Library1.dll将被添加到测试应用程序项目的引用。被引用的项目DLL“Referencelibrary”将被省略。有关更多详细信息,请参阅Flexible Project-to-Project References。
如果要嵌入的ReferenceLibrary的DLL文件分享帮助的NuGet包内,并参考测试应用程序的项目,你可以添加ReferenceLibrary项目基准测试应用程序项目中添加引用项目分享帮助 或集ReferenceLibrary后.DLL为LIBRARY1专案的依赖,你可以添加下面的条目为Library1.csproj,然后打包分享帮助并安装该软件包通过的NuGet来测试应用程序:
<ItemGroup>
<Reference Include="ReferenceLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ReferenceLibrary.1.0.0\lib\net461\ReferenceLibrary.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
更新:
如果我们想要在Library1的nuget包中嵌入ReferenceLibrary的DLL,我们应该确保ReferenceLibrary.dll包含在Library1包中,而不管我们如何嵌入DLLS。因此,当我们打包Library1包并将目标设置为lib文件夹时,您可以将ReferenceLibrary.dll添加到Library1.nuspec文件中作为文件。下面是我的Library1.nuspec:
<?xml version="1.0"?>
<package >
<metadata>
<id>Library1</id>
<version>1.0.0</version>
<authors>xxxx</authors>
<owners>xxxx</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package description</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2017</copyright>
<tags>Test</tags>
</metadata>
<files>
<file src="..\Library1\bin\Debug\Referencelibrary.dll" target="\lib\net461" />
<file src="..\Library1\bin\Debug\Library1.dll" target="\lib\net461" />
</files>
</package>
需要注意的是:您还需要包括在Library1.nuspec的Library1.dll。
“这样我就不必发布2个独立的nuget包”:为什么这对你来说如此重要? –
此问题的任何更新?你能从Leo的建议中获得有用的信息吗? –
嗨Jeroen,因为我通常对我的所有代码使用分层的方法。我经常做的事情是将我的数据访问层与其他层分开。因此,在这种特定情况下,我不想发布单独的存储库nuget软件包。 – Zorthgo