NuGet: 'X' already has a dependency defined for 'Y'

asp.netIisNuget

asp.net Problem Overview


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

asp.net Solutions


Solution 1 - asp.net

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.

Solution 2 - asp.net

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)

Solution 3 - asp.net

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

Solution 4 - asp.net

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]

Solution 5 - asp.net

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.

Solution 6 - asp.net

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 !!

Solution 7 - asp.net

  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

Solution 8 - asp.net

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.

Solution 9 - asp.net

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.

Solution 10 - asp.net

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

Done.

Solution 11 - asp.net

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTN.View Question on Stackoverflow
Solution 1 - asp.netTN.View Answer on Stackoverflow
Solution 2 - asp.netRobynView Answer on Stackoverflow
Solution 3 - asp.netHuckFin.7bView Answer on Stackoverflow
Solution 4 - asp.netBoris ZinchenkoView Answer on Stackoverflow
Solution 5 - asp.netStewertView Answer on Stackoverflow
Solution 6 - asp.netszc0025View Answer on Stackoverflow
Solution 7 - asp.netRahulView Answer on Stackoverflow
Solution 8 - asp.netHernán Dario Velásquez GarcíaView Answer on Stackoverflow
Solution 9 - asp.netuser7013486View Answer on Stackoverflow
Solution 10 - asp.netAnshul RawatView Answer on Stackoverflow
Solution 11 - asp.netGenivanView Answer on Stackoverflow