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'.
2

11 Answers 11

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.

7
  • 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 1, 2016 at 5: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. Aug 5, 2016 at 19:02
  • This works for me. In my case I was trying to install SQLite-net PCL (Xamarin). Visual Studio is 2013 Ultimate. Oct 19, 2016 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) Oct 28, 2016 at 8: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. Dec 13, 2016 at 10:55
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)

1
  • 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, 2017 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
1
  • 1
    This did it for me.
    – Naner
    Nov 29, 2017 at 16:57
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]
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.

2
  • Thanks for the info. I had the same issue + updating NuGet to 4.0.0 / not as default and changing NuGet to v4 for this one build config that was failing did the job! Mar 24, 2017 at 12:54
  • but how do you do that?
    – ympostor
    Jun 18, 2017 at 13:08
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 !!

4
  • how to do that??
    – ympostor
    Jun 18, 2017 at 13:08
  • I am getting this EXACT same issue.
    – Jess
    Jun 19, 2017 at 19:26
  • See also: stackoverflow.com/questions/44532170/…
    – Jess
    Jun 19, 2017 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, 2017 at 2: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
1
  • 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, 2018 at 8: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.

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
0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.