简体   繁体   English

如何强制将NuGet依赖项放在目标目录中?

[英]How to force a NuGet dependency to be in the target directory?

I'm trying to publish a project on NuGet staging server . 我正在尝试在NuGet 登台服务器上发布项目 The project has two dependencies: Mono.Cecil and ILRepack. 该项目有两个依赖项:Mono.Cecil和ILRepack。

When installing my project at project level: 在项目级别安装我的项目时:

  • Mono.Cecil dependency is installed automatically at project level. Mono.Cecil依赖项会在项目级别自动安装。 I can also find it in the target directory of the project. 我也可以在项目的目标目录中找到它。

  • ILRepack dependency is installed too, but at solution level. ILRepack依赖项也已安装,但处于解决方案级别。 There is no mention of ILRepack.dll in the target directory. 在目标目录中没有提及ILRepack.dll

Since my project requires both Mono.Cecil and ILRepack to be actually in the target directory, this is rather annoying. 由于我的项目要求Mono.Cecil和ILRepack实际上都在目标目录中,所以这很烦人。 There is no “Copy Local” to check like for ordinary references. 没有“复制本地”可以像普通参考一样进行检查。

How do I force NuGet dependencies to be at the scope of the project and to be copied to target directory during the build? 如何在构建过程中强制NuGet依赖项位于项目范围内并复制到目标目录?

Found it. 找到了。 The problem was that the NuGet package metadata was referencing ILRepack , when the one I actually needed is ILRepack.Lib . 问题是NuGet包元数据引用了ILRepack ,而我真正需要的是ILRepack.Lib

Since ILRepack package doesn't contain the assemblies to be used in a project, but rather an executable to be called directly, it was forced to be installed at the scope of the solution, and there are no actual references at project level. 由于ILRepack软件包不包含要在项目中使用的程序集,而是包含可以直接调用的可执行文件,因此它被强制安装在解决方案范围内,并且在项目级别没有实际引用。 Makes sense. 说得通。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM