[英]Nuget pack and install third party dependencies, not located in the bin folder
I am trying to create a NuGet package that can contain and deploy third party dependencies, these are dll's and executables that my program needs to run.我正在尝试创建一个 NuGet package 可以包含和部署第三方依赖项,这些是我的程序需要运行的 dll 和可执行文件。 There are a few caveats to this issues though.
不过,这个问题有一些警告。
If I can't place them one level up I could probably make this work installing them into a folder within the bin folder.如果我不能将它们放在上一层,我可能会完成这项工作,将它们安装到 bin 文件夹中的文件夹中。 These requirements are a little weird but I'm a bound by work that has already been done and don't have power to change it.
这些要求有点奇怪,但我受制于已经完成的工作,没有能力改变它。
A small example of one of the many things I have tried:我尝试过的许多事情之一的一个小例子:
<Content Include="x86\SQLite.Interop.dll">
<buildAction>Embedded Resource</buildAction>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<copyToOutput>true</copyToOutput>
<PackagePath>lib</PackagePath>
<PackageOutputPath>..\SQLite</PackageOutputPath>
<Pack>true</Pack>
</Content>
Use this:用这个:
<ItemGroup>
<Content Include="x86\SQLite.Interop.dll">
<buildAction>Embedded Resource</buildAction>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<copyToOutput>true</copyToOutput>
<PackagePath>lib\$(targetframework)</PackagePath>
<Pack>true</Pack>
</Content>
</ItemGroup>
<PropertyGroup>
<PackageOutputPath>..\SQLite</PackageOutputPath>
</PropertyGroup>
Then , re-pack your project.然后,重新打包您的项目。 Before you install this new version, please delete all old nuget caches under
C:\Users\xxx\.nuget\packages
, then reinstall the new version.在安装此新版本之前,请删除
C:\Users\xxx\.nuget\packages
下所有旧的 nuget 缓存,然后重新安装新版本。 After that, re-build your main project and then you will get what you want.之后,重新构建你的主项目,然后你会得到你想要的。
Update更新
Try to pack the files into content node:尝试将文件打包到内容节点中:
<ItemGroup>
<Content Include="x86\SQLite.Interop.dll">
<buildAction>Embedded Resource</buildAction>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
</ItemGroup>
Then , right-click on the Project--> Pack .然后,右键单击 Project--> Pack 。 And you should not use any other nuspec file to pack with.
而且你不应该使用任何其他 nuspec 文件来打包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.