简体   繁体   English

Nuget 打包并安装第三方依赖,不在 bin 文件夹中

[英]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.不过,这个问题有一些警告。

  1. When installing the package the dlls need to be in one directory above the bin folder, I can already make them install into the bin folder thats not what I need .安装 package 时,dll 需要位于 bin 文件夹上方的一个目录中,我已经可以将它们安装到我不需要的 bin 文件夹中。 (This makes this question different than others I have found) (这使得这个问题与我发现的其他问题不同)
  2. I would prefer using the packing via the.csproj file instead of the.nuspec if possible.如果可能的话,我更喜欢通过 .csproj 文件而不是 .nuspec 使用打包。

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.

相关问题 如何打包 nuget package 以安装我们的项目 dll 然后分别安装第三方 nuget 包 - How to pack nuget package in such a way that it install our project dlls and then install 3rd party nuget packages separately 如何在.NET Core中将第三方nuget包(依赖项)全局部署到服务器? - How to deploy third party nuget packages (dependencies) globally to the server in .NET Core? 如何将第三方dll从bin文件夹移动到ASP.NET Web Forms项目中的另一个文件夹? - How to move third party dlls from bin folder to another folder in ASP.NET Web Forms project? Nuget包无法安装 - Nuget pack won't install 依赖关系未复制到bin文件夹 - Dependencies not copied to bin folder 使 dotnet 发布使用来自 bin 文件夹而不是来自 nuget 缓存的依赖项 - Make dotnet publish use dependencies from bin folder and not from nuget cache Nuget pack无法识别依赖项中的$ version $ - Nuget pack does not recognize $version$ in dependencies 在nuget包中添加第三方COM参考 - Add third party COM reference in nuget package 如何安装第三方应用程序 - How to install a third party application 我的程序需要使用位于 Debug 文件夹中的第三方软件,但程序显示找不到配置文件。 C# - My program needs to use a third-party software located in the Debug folder, but the program says no config file was found. C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM