[英]nuget package with multiple DLL's
I have created a nuget package via Nuget Package Explorer with the following content. 我已经通过Nuget Package Explorer创建了一个nuget包,其中包含以下内容。
lib
-- CPPLib.dll
-- DotNetWrapper.dll
CPPLib.dll is the main library with logic implementation (in native C++), and DotNetWrapper.dll is the wrapper which will be reference in C# projects. CPPLib.dll是具有逻辑实现的主库(在本机C ++中),而DotNetWrapper.dll是将在C#项目中引用的包装器。
When I try to install this nuget package, I got the following error 当我尝试安装此nuget包时,出现以下错误
Install failed. Rolling back...
Install-Package : Failed to add reference to 'CPPLib.dll'.
At line:1 char:16
+ install-package <<<< -id MyPackage
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
I know everything in "lib" folder inside the package will be installed as reference, which explains why the native CPPLib.dll can't be installed to a C# project. 我知道包中的“lib”文件夹中的所有内容都将作为参考安装,这解释了为什么本机CPPLib.dll无法安装到C#项目中。
Then I tried to move the CPPLib.dll into "content" folder in the package like this 然后我尝试将CPPLib.dll移动到包中的“content”文件夹中
content
-- CPPLib.dll
lib
-- DotNetWrapper.dll
Then the package can be installed, but the project will not build as DotNetWrapper.dll can not find CPPLib.dll in the same folder. 然后可以安装包,但是项目不会构建,因为DotNetWrapper.dll无法在同一文件夹中找到CPPLib.dll。
How can I get around this issue? 我该如何解决这个问题? Is it possible to somehow put everything in lib folder and only "expose" DotNetWrapper.dll from the package?
有可能以某种方式将所有内容放在lib文件夹中并且只从包中“暴露”DotNetWrapper.dll吗?
you need to work with files and references in your nuspec file: 您需要使用nuspec文件中的文件和引用:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
...
<references>
<reference file="DotNetWrapper.dll" />
</references>
</metadata>
<files>
<file src="bin\Release\DotNetWrapper.dll" target="lib" />
<file src="bin\Release\CPPLib.dll" target="lib" />
</files>
</package>
so you define files to put in your package with "files", and tell the nuget that your only reference to add is wrapper DLL with "references". 所以你用“文件”定义要放在包中的文件,并告诉nuget你唯一的add引用是带有“references”的包装DLL。
Pls mention that these tags are on different level - "references" must be inside "metadata", but "files" are sibling to "metadata" 请注意这些标签位于不同的级别 - “引用”必须在“元数据”内,但“文件”是“元数据”的兄弟
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.