我有一个看起来像这样的nuspec文件:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>MyDll.Service</id>
<version>1.0.0</version>
<title>MyDll.Service</title>
<authors>MyDll</authors>
<owners>MyDll</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Description</description>
<copyright>Copyright © 2017</copyright>
<dependencies>
<dependency id="SomeDll" version="1.0.0" />
</dependencies>
<references>
<reference file="MyDll.Service.Context.dll" />
</references>
</metadata>
<files>
<file src="..\..\Folder\MyDll.Service.Context\bin\Release\MyDll.Service.Context.dll" target="lib\net452"/>
<file src="..\..\Folder\MyDll.Service\bin\Release\MyDll.Service.dll" target="lib\net452"/>
</files>
</package>
这会生成一个包含2个dll的nuget包。项目本身只引用MyDll.Service.Context.dll
(这正是我想要的)。
我正在使用注入在MyDll.Service.dll
的任何地方插入MyDll.Service.Context.dll
。我唯一的问题是,当我构建时,dll MyDll.Service.dll
不会被拉入主项目的bin文件夹中。只有MyDll.Service.Context.dll
。这是有道理的,因为我只引用了上下文dll。
我的问题是,如何在构建和发布项目时将MyDll.Service.dll
拉入bin文件夹,而无需在项目中引用该dll?
编辑:
根据评论中的建议,我尝试使用MSBuild执行此操作。我将我的nuspec更改为以下内容:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>MyDll.Service</id>
<version>1.0.0</version>
<title>MyDll.Service</title>
<authors>MyDll</authors>
<owners>MyDll</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Description</description>
<copyright>Copyright © 2017</copyright>
<dependencies>
<dependency id="SomeDll" version="1.0.0" />
</dependencies>
<references>
<reference file="MyDll.Service.Context.dll" />
</references>
</metadata>
<files>
<file src="..\..\Folder\MyDll.Service.Context\bin\Release\MyDll.Service.Context.dll" target="lib\net452"/>
<file src="..\..\Folder\MyDll.Service\bin\Release\MyDll.Service.dll" target="lib\net452"/>
</files>
</package>
不幸的是,所有这一切都是因为我的MyDll.Service.dll
dll在我的包中出现两次,一次出现在build文件夹中,一次出现在lib文件夹中。但是,在构建时,dll仍然不在文件夹中。