NuGet: 'X' already has a dependency defined for 'Y' - asp.net

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

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.

I fixed a similar issue in my solution by:
Opening up a command prompt
Navigating to the .nuget folder in my solution
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)

I tried the update, but it did not work for me. Helped:
Uninstall NuGet => Tools => Extensions and update => Installed
Install NuGet
Reload Visual Studio

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]

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.

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

Go to the link https://www.nuget.org/packages/ClosedXML/0.64.0
Search your NuGet packages
See the all version of related packages
Install the lower version of packages

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.

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.

Go to Tools.
Extensions and Updates.
Update Nuget and any other important feature.
Restart.
Done.

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

Related

Unable to restore nuget/nexus packages for .netcore and .netframework in same solutions from Jenkins

In my solution, I have .NET Core and .NET Framework projects. I am facing the below error (which is a .NET Core project) while compiling the solution through Jenkins:
error NETSDK1064: Package IBM.Data.DB2.Core, version 1.3.0.100 was not
found. It might have been deleted since NuGet restore. Otherwise,
NuGet restore might have only partially completed, which might have
been due to maximum path length restrictions.
The Error Message is pretty self-explanatory. Try to restore the package by either right clicking on the solution and selecting "Restore Nuget Packages" in your IDE, or run the below command in the package manager console.
nuget restore YourSolution.sln
Alternatively, you can also install the package using the below command
Install-Package IBM.Data.DB2.Core -Version 1.3.0.100
Check for any error messages while restoring or installing packages, in case there are any file path issues.

Specified Web Pages version “3.0.0.0” could not be found. Update your web.config to specify a different version. Current version: “2.0.0.0”

I have this problem in my web service:
Specified Web Pages version “3.0.0.0” could not be found. Update your
web.config to specify a different version. Current version: “2.0.0.0”
Install Microsoft.AspNet.WebPages nuget package by entering this line in package manager console:
Install-Package Microsoft.AspNet.WebPages -Version 3.0.0
Or find and install it using Nuget Package Manager.
Go to the Nuget Package Manager in Visual Studio Code. Search for Microsoft.AspNet.WebPages and update this package if you already have the latest one the you should try to downgrade one version previous.
Or
You can run the below command in Package Manager Console in Visual Studio:
Install-Package Microsoft.AspNet.WebPages
This will resolve the issue.

Which version of Microsoft.AspNet.Mvc is supported by .NETCoreApp v2.2?

I am working on a Ubuntu 18.04 environment using Visual Studio Code and .NET Core v2.2.
After including a few existing projects into a solution that I'm working on, I ran into errors when I tried to compile stating that the namespace "Microsoft.AspNet.Mvc" could not be found.
So, I added a package reference for the projects that were complaining by using the dotnet CLI:
dotnet add package Microsoft.AspNet.Mvc --version 3.0.20105.1
But now when I try to dotnet restore or dotnet msbuild the solution file, I'm getting warnings reporting that:
warning NU1701: Package 'Microsoft.AspNet.Mvc 3.0.20105.1' was
restored using '.NETFramework,Version=v4.6.1' instead of the project
target framework '.NETCoreApp,Version=v2.2'.
This package may not be fully compatible with your project.
I would like to figure out which package version of Microsoft.AspNet.Mvc I need to install in order to be compatible with .NET Core v2.2.
I realize that this is just a warning and using the .NETFramework v4.6.1 may be okay, but I have been debugging a very strange issue that is only happening on a Ubuntu environment, so I would like to determine whether package versioning is a problem.
I have tried Google searching to determine which version of MVC is compatible with .NET Core 2.2, but I have yielded any useful results.
Does anyone know the answer to this question? Or would you be able to point me in the direction of a source that can answer it?

Install a Nuget package ignoring ONE dependency

I'm sure this has been asked before, but I spent almost an hour searchin Stackoverflow and haven't found any answer. Sorry if I missed it.
I need to install a Nuget package without one (just one) of its dependencies.
In particular, I'm adding SignalR to an ASP.NET MVC app and I need to skip jQuery-dependency because I already have it added manually, from a CDN-hosting. Don't need it in my project.
But I need all the other dependencies, and I need them managed by Nuget, not manually. So if the author adds some new dependency to the next version, - like Owin or something, - it will be pulled in automatically.
The only solution I came up with is to install the package with all the dependencies and then run
Uninstall-Package jQuery -Force
Is this ok? It seems a bit "hacky" to me, or is it fine? Are there any other options?
I need to install a Nuget package without one (just one) of its
dependencies.
Not possible currently through Command Line, because Install-Package doesn't have any parameter to skip a particular dependency (as visible in the latest microsoft docs reference).
Use the below command if you want to avoid all of the Dependencies (as you can't skip a particular dependency because it is nowhere quoted in Microsoft Docs):
Install-Package Microsoft.AspNet.SignalR -IgnoreDependencies
Detail about the parameter from Install-Package document from Microsoft:
Install-Package [-Id] <string> [-Version <string>] [-IgnoreDependencies]
[-ProjectName <string>] [-Source <string>] [-IncludePrerelease] [-FileConflictAction]
[-DependencyVersion <dependencyVersion>] [-WhatIf]
IgnoreDependencies : Installs only this package and not its dependencies
Is this ok? It seems a bit "hacky" to me, or is it fine? Are there any other options?
The simple answer is "It depends on the version of jQuery-dependency which you have added manually ".
You will notice that the dependency restrictions of Microsoft.AspNet.SignalR is: jQuery (>= 1.6.4):
So if the version of jQuery which you have installed manually is higher than the version of dependency restrictions of Microsoft.AspNet.SignalR, you can uninstall the jQuery, then install the package Microsoft.AspNet.SignalR. Therefore, your method is feasible.
Note: After install the package Microsoft.AspNet.SignalR, you can update the version of the package jQuery, if you want.
In contrast, the version of jQuery which you have installed manually is lower than 1.6.4 and you do not want to use the high version of that package, you can not do it with your method, otherwise, NuGet will install the jQuery with version 1.6.4 after install the package Microsoft.AspNet.SignalR.
What I ended up doing is install jQuery nuget package and then simply remove files from the /Scripts directory
Now all the jQuery-dependent packages are happy and my project is not bloated with unneeded files

issues for NuGet after migrating a c# project

i'm trying to migrate a project into my visual studio 2012.
On the Manage NuGet Packages, I have this issue:
"Some NuGet Packages are missing from this solution. Click to restore from your online package sources"... but when i click on the restore button, it appears this issue:
"an error occurred while trying to restore packages: Unable to find version '4.1.0-alpha-121112' of package 'Microsoft.AspNet.WebApi'. "
i'm using .NET Framework 4
How can i solve?
Thanks in advance....
The problem is that version '4.1.0-alpha-121112' of package Microsoft.AspNet.WebApi does not exist on NuGet.org. It is not available on MyGet from the ASP.NET Web Stack Nightly package source either. So NuGet cannot restore it since it is no longer available.
Looking at Symbol Source it looks like this NuGet package was at one point available from the ASP.NET Web Stack Nightly package source on MyGet but it no longer seems to be available. I suspect they have deleted the old packages from that MyGet package source.
Unless you can find the original NuGet package, you will either have to manually remove the NuGet package reference, by editing the project file and packages.config file, and reinstall a version that exists.
1) Make sure you upgrade to the latest NuGet.
2) Make sure you're doing package restore "The Right Way" http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html
That should resolve the issue.
if still this ain't solve you can see this Rightway to migrate

Resources