简体   繁体   中英

Ignoring Dependencies in Nuget Package

I have a package which has 5 dependencies -- one of which is MVC3. While installing this package, I want to ignore the dependency on MVC3 alone. Is there a way I can do that?

In the Nuget Package Manager Console, there's an option to ignore dependencies when installing packages --

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

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

Note the line beginning <package . When creating your own package you can exclude individual packages using 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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