Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 543
Sammy Avatar asked Apr 28 '15 01:04

Sammy


People also ask

Do NuGet packages include dependencies?

Any time a package is installed or reinstalled, which includes being installed as part of a restore process, NuGet also installs any additional packages on which that first package depends. Those immediate dependencies might then also have dependencies on their own, which can continue to an arbitrary depth.

Where can you find information about NuGet packages and their dependencies?

A Visual Studio project is defined by a . csproj file, which is an XML file that holds different configuration settings for the project. The information about the NuGet package dependencies for your project is stored in this . csproj file.

How do I update NuGet package references?

To manage your package sources, select the Settings icon or select Tools > Options. In the Options window, expand the NuGet Package Manager node and select Package Sources. To add a source, select +, edit the Name, enter the URL or path in Source, and then select Update.


2 Answers

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.

like image 33
Icy Defiance Avatar answered Oct 17 '22 00:10

Icy Defiance


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

like image 167
Joseph Devlin Avatar answered Oct 17 '22 02:10

Joseph Devlin