Nuget添加非托管文件



我使用下面的*。目标文件添加构建操作

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
        <None Include="$(MSBuildThisFileDirectory)libeay32.dll">
            <Link>libeay32.dll</Link>
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Include="$(MSBuildThisFileDirectory)COMAssinaDocs.dll">
            <Link>COMAssinaDocs.dll</Link>
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Include="$(MSBuildThisFileDirectory)InterOps.ComAssinaDocs.dll">
            <Link>InterOps.ComAssinaDocs.dll</Link>
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Include="$(MSBuildThisFileDirectory)ssleay32.dll">
            <Link>ssleay32.dll</Link>
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
    </ItemGroup>
</Project>

,这是nuspec:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
    <metadata>
        <id>xxx.Providers.SignDocs</id>
    </metadata>
    <files>
        <file src="binReleasexxx.Providers.SignDocs.targets" target="build" />
        <file src="binReleasexxx.Providers.SignDocs.dll" target="libnet45" />
        <file src="binReleasexxx.Providers.SignDocs.Impl.dll" target="libnet45" />       
  </files>
</package>

我正在使用这段nuget文档来构建这个包:

在包中包含MSBuild道具和目标

基本上我想要的是得到一些非托管dll复制到项目的输出文件夹使用包,即使我是按照说明目标项目文件的目标部分没有添加,因此文件没有复制到输出目录。我错过了什么?

更新

可以使用下面的配置使其工作。

xxx.Providers.SignDocs.targets

<None Include="$(MSBuildThisFileDirectory)libeay32.dll">
  <Link>libeay32.dll</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)COMAssinaDocs.dll">
  <Link>COMAssinaDocs.dll</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)InterOps.ComAssinaDocs.dll">
  <Link>InterOps.ComAssinaDocs.dll</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)ssleay32.dll">
  <Link>ssleay32.dll</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>xxx.Providers.SignDocs</id>
  </metadata>
  <files>
    <file src="....toolslibeay32.dll" target="build" />
    <file src="....toolsCOMAssinaDocs.dll" target="build" />
    <file src="....toolsInterOps.ComAssinaDocs.dll" target="build" />
    <file src="....toolsssleay32.dll" target="build" />
    <file src="binReleasexxx.Providers.SignDocs.targets" target="build" />
    <file src="binReleasexxx.Providers.SignDocs.dll" target="libnet45" />
    <file src="binReleasexxx.Providers.SignDocs.Impl.dll" target="libnet45" />
  </files>
</package>

target文件需要包含在nuspec文件的'package/files'元素中,否则它不会包含在包中。它需要一个"构建"的目标。目标文件也需要与包命名相同。

最新更新