Install a Nuget package ignoring ONE dependency - asp.net

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

Related

Best way to force an update of a transitive nuget package dependency?

Consider a .NET Core application (A), which references a third-party nuget package (B) using the PackageReference model. Package B has it's own dependency on another package (C):
A -> B -> C
Package B declares a dependency on C with a version constraint of >= 1.0.0. A has no compile-time usages of C and does not reference it directly - C is a transitive run-time dependency.
However, version 1.0.0 of package C (which is picked up by the build) has a bug in it. The bug has been fixed in a more recent version, released to nuget with an incremented minor-version (e.g. v1.1.0).
By default, my build doesn't pick up this latest version. I believe this is due to the 'Lowest applicable version' rule, described here:
https://learn.microsoft.com/en-us/nuget/concepts/dependency-resolution#dependency-resolution-rules
What is the recommended approach for forcing the build to pick up the bug-fix 1.1.0 version of package C?
One solution is to explicitly reference the 1.1.0 version of package C from A. However, this feels like I'm breaking encapsulation, as A shouldn't need to know anything about C.
Ideally, the author of package B would update their dependency on C to use the newer version, but I don't have any control over this package.
I also tried using a Directory.Build.props file at the root of the solution, to try and force the version to be updated across the whole solution:
<ItemGroup>
<PackageReference Update="SomePackage.C" Version="1.1.0" />
</ItemGroup>
...but this doesn't work (I assume the 'lowest applicable version' rule still applies). It does work if you use Include instead of Update, but that simply installs the package into all the projects in the solution.
I'd like to be able to supply some 'policy' to the build process, to force the updated version to be picked up, but I've not found a way to do this.
Note: my actual example is more complex than the one outlined here. Both B and C are widely-used Microsoft ASP.NET packages, and C appears in dozens of places in the dependency graph (my own application never references that code directly).
The best way to force an update of a transitive Nuget package dependency is to update the directly referenced package to a newer version that includes the updated transitive dependency
Open the Package Manager Console in Visual Studio. You can do this by going to Tools > NuGet Package Manager > Package Manager Console.
Run the command Update-Package -Version . For example, if the directly referenced package is Newtonsoft.Json, the command would be Update-Package Newtonsoft.Json -Version 12.0.3. This will update the directly referenced package and also update any transitive dependencies.
Check your project to see if the transitive dependency has been updated. You can do this by going to Solution Explorer and expanding the References folder.
If the package still doesn't update, try deleting the packages folder in your solution and then run the Update-Package command again. This will force NuGet to download the latest versions of all the packages and their dependencies.
In some cases, you may also need to update the project file (.csproj) to include the latest version of the dependency.

Could not install package 'Splat 2.0.0'

Trying to install Splat 2.0.0 into Xamarin Forms project results with error:
Could not install package 'Splat 2.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
How to resolve this issue please?
Thanks,
AG
I found this on the GitHub of your tool:
Please use Splat 1.6.2 when targeting PCL projects. v2.0 and onwards is netstandard only. There will be no updates to the 1.6.x series so if you need to patch the release then please fork and maintain your own copy/build from source.
It seems they stopped supporting PCL. So as a solution I suggest using Splat 1.6.2 as that seems to support ¨PCL. Good luck

How to add spiderable 1.0.8 to my meteor project?

Currently the latest public version of the Spiderable package is 1.0.7 (atmosphere link). However on Github the version has been bumped to 1.0.8 (4 days ago).
I need the features from the 1.0.8 update. What's the best way for me to use the 1.0.8 version? I've tried:
meteor add spiderable#1.0.8
But it didn't work, the output was: error: no such version spiderable#1.0.8 .
This version of spiderable has not yet been published by MDG. This is why it says no such version.
While a package is being developed the version may be higher than the version available for use. When it has been tested its usually published along the next meteor version.
There may still be more changes to the package until its published.
If you want to use the package anyway you can copy the spiderable directory from github into a packages/spiderable directory. This may not work with certain dependency errors depending on whether another package using spiderable is required.
The second is to use the github version of meteor. Which is to clone the meteor project using git clone https://github.com/meteor/meteor then use the meteor binary (with the full absolute path) to run your project instead of meteor on its own.

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

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

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

Resources