Please help me understand: I have a Visual Studio project. It has Nuget package manager enabled. I install several libraries. The library versions are shown in packages.config. Each library has a corresponding entry in References.
Now, say I want to change the library version from, say, 2.2.0 to 2.1.0. How I do this? At first I assumed you could just change the version number in packages.config. But when I do this, and get Nuget to download an earlier version of the library, the project references are not changed.
Do I have to manually remove each and every reference in the project to 2.2.0 and replace it with 2.1.0?
I get the feeling I'm "doing it wrong", but there doesn't seem to be any examples I can find of anyone doing it right.
Thanks for any help!
Using jQuery as an example:
If you want to rollback to a previous version you can run the Uninstall-Package jQuery and Install-Package jQuery -Version 2.1.0 commands from the package manager console.
Also, the package nuget page will have a list off all the versions available. EX: jQuery
All of this and more available in the nuget Docs
You can't simply change the version in the config file since your project still holds a reference to the binaries, so the binaries need to be replaced too.
Now, I'm not entirely sure if there is a "downgrade" Powershell command but you can certainly uninstall the specific package and then install a lower version. By using the Package Manager Console. So from within Visual Studio:
Go to the View menu -> Other Windows -> Package Manager Console
Select the Default Project from the dropdown list
Then run the following command to uninstall the package
The command to uninstall is...
Uninstall-Package YOUR_PACKAGE_NAME
To install a lower version, run this command...
Install-Package YOUR_PACKAGE_NAME -Version 1.0
These and other commands are very well documented in The Package Manager Console Powershell Reference
Uninstall-Package Command
Install-Package Command
Related
I would like to install a package i downloaded called swatch.AutofacConfiguration.1.3.0.nupkg
I have it stored locally. I just dont know how to install it.
I have tried using commands like
nuget install
nuget add -Source some/directory my.nupkg
I would like to add it to my solution please
The first thing I would suggest is instead of using the PMC (Package Manager Console) in Visual Studio use the Nuget Package Manager (which you can find by typing into the search bar at the top of the IDE).
Since the file extension is nupkg you can most definitely find it on there and have visual studio handle the installation and referencing. I hope that helps.
We have dozens of solutions in a repository and we're retargeting every project to net472 from net462. Currently our best bet is to open each and every solution in Visual Studio and execute the following command in the Package Manager Console.
Update-Package -Reinstall -IgnoreDependencies
As far as I'm aware, the PM console cannot be used outside Visual Studio, so this method of course is not very efficient, so what I was thinking about is using the nuget.exe tool for this. However at first glance I could not find any equivalent operation or argument set.
The documentation at this moment says the following
For all packages, delete the package folder, then run nuget install.
For a single package, delete the package folder and use nuget install
to reinstall the same one.
So based on this I tried to delete the packages folder and run nuget install for a project, so I expected it to do a re-install. However, while it installed the package indeed (to packages), it does not touch the packages.config (for retargeting).
Is anyone aware of any kind of possible way to automate this process?
How to achieve full NuGet reinstall using nuget.exe CLI?
That command cannot get what you want.
As far as I know, nuget install should be with packages.config file and it will not update the nuget framework version of packages.config file automatically.
So whenever you change the target framework version of your project, using that command will not update the target framework version of the nuget package.
So only update-package -reinstall command under Package Manager Console will update the target framework version of packages.config file.
And also Package Manager Console cannot access multiple solutions so you have to open each solution to run that command.
Although it may be possible to achieve your expectations with PowerShell scripts, but it is too complex so that it is easier to open each solution and then run the command.
As a suggestion,
1) open each solution on VS to run update-package -reinstall command.
2) And migrating from packages.config to PackageReference may be a good choice. In this case, the nuget packages will automatically adapt to the corresponding project target framework version.
Before doing this,you can make a backup of your project.
3) If these all do not meet your requirements, you could suggest a feature on our User Voice Forum to report your desire for automation. After that, you can share the link here and anyone who is interested in it will vote it so that it will get more attention from Microsoft.
I have a large project that has about a dozen dependencies. I have tried to install them all but ran into an error from VS. I am using Visual Studio 2015
"An error occurred while trying to restore packages: Unable to find version '3.0.3.1' of package'Lucene.Net.Core'."
Now I have a solution which I can use that is by the same name as this package, but VS refuses to let me updates, remove, or change ANYTHING related to these packages and asks that I restore the packages. I am entirely lost here friends, what should I do?
P.S. the two sources I am using for my package sources are:
https://www.nuget.org/api/v2/
https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/
The same error occurs for Lucene.Net.Contrib, pstsdk.net, and various packages.
One thing to check for is if your project is built on a version of the NET framework that is less than or equal to the target framework the package has.
If your project is a NET 4.5 based project, but the nuget package has a NET 4.5.2... then the package manager will error out.
"An error occurred while trying to restore packages: Unable to find version '3.0.3.1' of package'Lucene.Net.Core'."
When I use the packages sources which you provided, I found that only two versions (4.8.0 & 4.9.0) of package"Lucene.Net.Core" not have the version '3.0.3.1'.
Pay Attention:
I noticed that the author of this package have updated this package at March 11, 2017(3/11/2017), and only release the version 4.8.0 & 4.9.0. So this must be the reason for NuGet restore failed.
Besides, you said:
I have a solution which I can use that is by the same name as this
package, but VS refuses to let me updates, remove, or change ANYTHING
related to these packages
If you want to remove those error packages, you can try to use below command to force uninstall those packages:
Uninstall-Package Lucene.Net.Core -Force
Or you can delete this package from the package folder and delete the package list from the package.config.
Then install the correct version of the packages.
Although I was not able to get any of the posted answers to work, I ended up removing the project entirely and reinstalling VS, my project, and its dependencies. This ended up working.
Another thing to check is that the package manager configuration settings in visual studio list the public nuget feed (and if the feed is enabled too).
Good Day eveyone. I'm currently installing Xamarin.Forms Nuget Package but I repeatedly get this error whenever I trying to to install it.
Failed to retrieve information from remote source 'http://nuget.syncfusion.com/xamarin/FindPackagesById()?id='Xamarin.Forms''
I was able to install other packages but not this one. How can I solve this? Here's my printscreen.
What version of nuget are you running. You may need to try updating NuGet.
If that does not work or it is already updated, try to install the NuGet package using the Visual Studio Package Manager Console instead: In Visual Studio -> View -> Other Windows -> Package Manager Console
Then type: Install-Package PACKAGENAME -ProjectName PROJECTNAME You may need to repeat that for each project you want to install the package into.
I do the following steps:
Open VS Express 2013 for Web
Create Empty MVC 5 Project
Select Tools ➤ Library Package Manager ➤ Manage Nuget Package for Solutions
Install Ninject.MVC5.
When I run debug I saw this:
I am so confuse with this error since I am new to MVC and Ninject. I already use assembly redirect because It's seem it use System.Web.Mvc version 3.0.0.0, but it's still error.
Anyone can help me?
Uninstall ninject from your project and install it again:
Select Tools-> Library Package Manager-> Package Manager Console in Visual Studio to
open the NuGet command line and enter the following commands:
Install-Package Ninject
Install-Package Ninject.Web.Common
Install-Package Ninject.MVC5
If the error continues checks that the version of System.Web.Mvc is 5.0 not another.
First, Unistall the ninject you have Install with this code
Uninstall-Package Ninject.MVC5.
Note: you put a dot(.) at the end of MVC5, i think that gave you the error.
Now, you can Install the package again with these following code
Install-Package Ninject.MVC5
resource: https://www.nuget.org/packages/Ninject.MVC5/