101

I'm getting the following error in NuGet while trying to install package Microsoft.AspNet.Server.IIS

Attempting to resolve dependency 'Microsoft.AspNet.Loader.IIS.Interop (≥ 1.0.0-alpha4-10330)'.
Attempting to resolve dependency 'Microsoft.AspNet.Loader.IIS (≥ 1.0.0-alpha4-10330)'.
'Microsoft.AspNet.Loader.IIS' already has a dependency defined for 'Microsoft.AspNet.FeatureModel'.

How to resolve it?

UPDATE: Also, I'm getting the following:

Attempting to resolve dependency 'Microsoft.Framework.DependencyInjection (≥ 1.0.0-alpha4-10326)'.
'Microsoft.Framework.DependencyInjection' already has a dependency defined for 'Microsoft.Framework.ConfigurationModel'.
RBT
  • 24,161
  • 21
  • 159
  • 240
TN.
  • 18,874
  • 30
  • 99
  • 157
  • Have you tried updating Nuget to the latest? See http://stackoverflow.com/questions/23286522/can-not-install-nuget-package – jrummell Sep 08 '14 at 13:37
  • 2
    @jrummell I have: 2.8.50313.46, no update in VS 2013 currently. – TN. Sep 08 '14 at 13:39

11 Answers11

156

This was resolved by installing the latest NuGet Package Manager:

https://visualstudiogallery.msdn.microsoft.com/4ec1526c-4a8c-4a84-b702-b21a8f5293ca

Don't forget to restart Visual Studio.

RBT
  • 24,161
  • 21
  • 159
  • 240
TN.
  • 18,874
  • 30
  • 99
  • 157
  • 6
    I've the latest Nuget "NuGet Package Manager 2.8.60318.667" but I get "Install-Package : 'System.Collections' already has a dependency defined for 'Microsoft.NETCore.Platforms'". when trying to install "Install-Package Microsoft.AspNet.WebHooks.Custom.AzureStorage -Pre" – Gopi Aug 01 '16 at 05:36
  • 2
    I have the same issue as @TechJerk, in my situation I am trying to put a project into a nuget package. I can do it locally but not on the build server. On the build server I get 'System.Collections' already has a dependency defined for 'Microsoft.NETCore.Platforms'. Updating NuGet had no effect. – user3841460 Aug 05 '16 at 19:02
  • This works for me. In my case I was trying to install SQLite-net PCL (Xamarin). Visual Studio is 2013 Ultimate. – ramires.cabral Oct 19 '16 at 13:12
  • 2
    I'm having the same issue as @TechJerk but with `'System.Net.Http' already has a dependency defined for 'System.IO'` - I tried reinstalling & upgrading NuGet with no effect (I'm currently using version 2.8... and Visual Studio 2012) – Blundering Philosopher Oct 28 '16 at 08:34
  • 2
    If you're getting this error in TeamCity then you may also need to update the build step settings to use the latest nuget version available. – Steve Greatrex Dec 13 '16 at 10:55
  • Thanks, that fixed it straight away. – Jon649 Feb 02 '17 at 10:25
  • I actually had to follow my own instructions in updating nuget from my old answer. https://stackoverflow.com/a/10792036/511438 – Valamas Nov 26 '17 at 07:50
75

I fixed a similar issue in my solution by:

  1. Opening up a command prompt
  2. Navigating to the .nuget folder in my solution
  3. Running nuget update -self

This upgraded the copy of NuGet.exe that was in my solution from 2.8.0 to 3.4.4, which fixed the 'X' already has a dependency defined for 'Y' error that was stopping it from downloading SSH.NET automatically before building.

(If your solution doesn't have a copy of NuGet.exe in it - and it might not - then you should try the solution in TN's answer instead)

RBT
  • 24,161
  • 21
  • 159
  • 240
Robyn
  • 1,334
  • 10
  • 12
  • 1
    This is the one that fixed it for me, but I ran it on the build server instead. The logs for the failed build indicated the path to the NuGet.exe in question. – InteXX Nov 24 '17 at 16:46
20

I tried the update, but it did not work for me. Helped:

  1. Uninstall NuGet => Tools => Extensions and update => Installed
  2. Install NuGet
  3. Reload Visual Studio
RBT
  • 24,161
  • 21
  • 159
  • 240
HuckFin.7b
  • 325
  • 4
  • 13
8

I faced this error on outdated version of Visual Studio 2010. Due to project configuration I was not able to update this version to newer. Therefore, update of NuGet advised above did not fix things for me.

Root reason for the error in this and similar situations is in dependencies of the package you try to install, which are not compatible with .NET version available in your project.

Universal solution is not obligatory update of Visual Studio or .NET but in installation of older NuGet versions of the same package compatible with your system.

It is not possible to tell for sure, which of earlier versions will work. In my case, this command installed the package without any NuGet updates.

Install-Package X -Version [compatible version number]
Boris Zinchenko
  • 2,142
  • 1
  • 24
  • 34
5

I was getting this issue on our TeamCity build server. I tried updating NuGet on the build server (via TC) but that didn't work. I finally resolved the problem by changing the "Update Mode" of the Nuget Installer build step from solution file to packages.config.

RBT
  • 24,161
  • 21
  • 159
  • 240
Stewert
  • 101
  • 1
  • 3
4

I was getting the issue 'Newtonsoft.Json' already has a dependency defined for 'Microsoft.CSharp' on the TeamCity build server. I changed the "Update Mode" of the Nuget Installer build step from solution file to packages.config and NuGet.exe to the latest version (I had 3.5.0) and it worked !!

Jess
  • 23,901
  • 21
  • 124
  • 145
szc0025
  • 41
  • 3
  • how to do that?? – ympostor Jun 18 '17 at 13:08
  • I am getting this EXACT same issue. – Jess Jun 19 '17 at 19:26
  • See also: https://stackoverflow.com/questions/44532170/newtonsoft-json-already-has-a-dependency-defined-for-microsoft-csharp – Jess Jun 19 '17 at 19:55
  • Go to Build Configuration Settings, under Build Steps, Add a step for NuGet Installer as Runner type. change the "Update Mode" of the Nuget Installer build step from solution file to packages.config and NuGet.exe to the latest version – szc0025 Jun 26 '17 at 02:44
2
  1. Go to the link https://www.nuget.org/packages/ClosedXML/0.64.0
  2. Search your NuGet packages
  3. See the all version of related packages
  4. Install the lower version of packages
RBT
  • 24,161
  • 21
  • 159
  • 240
Rahul
  • 21
  • 3
  • This is actually a good solution in case your visual studio version is too low. In my case I have to work with VS2012, which does not support the newest version of NuGet. That automatically means I cannot always download the newest packages through the Manage NuGet Packages window. – Mixxiphoid Jan 22 '18 at 08:36
1

In my case I had to delete the file NuGet.exe in the Project folder/.nuget and rebuild the project.

I also have in NuGet.targets the DownloadNuGetExe marked as true:

<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">true</DownloadNuGetExe>

Hope it's helps.

0

The only solution that worked for me was to uninstall nuget completely from Visual Studio 2013 and then install it again with the obligatory restart of VS in between.

0
  1. Go to Tools.
  2. Extensions and Updates.
  3. Update Nuget and any other important feature.
  4. Restart.

Done.

Stephan Hogenboom
  • 1,543
  • 2
  • 17
  • 29
0

In a project using vs 2010, I was only able to solve the problem by installing an older version of the package that I needed via Package Manager Console.

This command worked:

PM> Install-Package EPPlus -Version 4.5.3.1

This command did not work:

PM> Install-Package EPPlus -Version 4.5.3.2
Genivan
  • 171
  • 2
  • 3
  • 10