0

我有一个如下所示的 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我唯一的问题是,当我构建时,dllMyDll.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.dlldll 在我的包中出现两次,一次在 build 文件夹中,一次在 lib 文件夹中。但是,在构建时 dll 仍然不在文件夹中。

4

0 回答 0