简体   繁体   English

忽略Nuget包中的依赖关系

[英]Ignoring Dependencies in Nuget Package

I have a package which has 5 dependencies -- one of which is MVC3. 我有一个包含5个依赖项的包 - 其中一个是MVC3。 While installing this package, I want to ignore the dependency on MVC3 alone. 在安装此软件包时,我想忽略对MVC3的依赖。 Is there a way I can do that? 有没有办法可以做到这一点?

In the Nuget Package Manager Console, there's an option to ignore dependencies when installing packages -- 在Nuget Package Manager控制台中,可以选择在安装软件包时忽略依赖项 -

Install-Package <package name> -IgnoreDependencies

I want to know if there is a way to mention a specific dependency to ignore, rather than ignoring all dependencies. 我想知道是否有办法提到要忽略的特定依赖项,而不是忽略所有依赖项。

If you are creating your own package you an add the following to your nuspec 如果您要创建自己的包,则将以下内容添加到您的nuspec中

<?xml version="1.0" encoding="utf-8"?>
<packages>
    <package id="MVC3" version="1.6.4" developmentDependency="true"     />
</packages>

Note the line beginning <package . 注意从<package开始的行。 When creating your own package you can exclude individual packages using developmentDependency="true" . 创建自己的包时,可以使用developmentDependency="true"排除单个包。 This will remove that package as a dependency. 这将删除该包作为依赖项。 The example I have provided is just dummy data. 我提供的示例只是虚拟数据。 You can read more about this feature here 您可以在此处详细了解此功能

The docs don't name any options like that. 文档没有列出任何类似的选项。 You'll have to ignore all dependencies, then install the ones you need separately. 您必须忽略所有依赖项,然后单独安装所需的依赖项。 I believe you'll also have to ignore all dependencies when calling Update-Package, and update the other dependencies individually, if you ever use that. 我相信你在调用Update-Package时也必须忽略所有依赖项,并且如果你曾经使用它,则单独更新其他依赖项。

If you're the creator of the package, you can set MVC3 as a development dependency , but that won't help if someone else controls the package. 如果您是该软件包的创建者,则可以将MVC3设置为开发依赖项 ,但如果其他人控制该软件包,那将无济于事。

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

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