visual studio: get list of NuGet packages updates for solution, in plain text - visual-studio

in Visual studio, I can see all the nugets installed in the solution by going to menu:
Tools > NuGet Package Manager > Manage Nuget Packages for Solution.
Then in the Updates tab, I can see, for every nuget installed in the solution, in what project(s) it is installed, what version(s), and the latest available version every NuGet can be updated to.
Is there any way to get all this info in a txt or css file or similar? maybe some console command?
(I can use get-package in Package Manager Console and it will give a list of every nuget installed in the solution, its version and the project it is installed, but no the latest available version...)

This might not be exactly what you want but it could be helpful. In .NET Core CLI 2.2+, you can run:
dotnet list package --outdated
This will list projects and any packages that have a newer version available (Installed vs Latest).
If you really wanted that in a txt file you could add > myreport.txt to the above command.

Related

URL for NuGet packages in Visual Studio 2019

Been working on another computer for several months. Recently, I did a git pull on another laptop which is not used very often. When I tried to build the solution, several projects failed due to missing NuGet packages.
I tried restoring the packages but this failed. Packages MSTest.TestFramework and MSTest.TestAdapter in particular were out-of-date, so I cleared the NuGet cache in Tools > Options > NuGet Package Manager > Clear All NuGet Cache(s).
But now when I right-click the project and Manage Nuget Packages..., no packages are displayed at all!
Back in Tools > Options > NuGet Package Manager > Package Sources only a single Machine-wide package source is listed, namely Microsoft Visual Studio Offline Packages. This points to a location on my location disk ("C:\Program Files (x86)\Microsoft SDKs\NuGetPackages", currently an empty folder).
New sources can be added, but what URL should be used to get the latest NuGet packages?
NuGet's documentation states that the endpoint is https://api.nuget.org/v3/index.json
source: https://learn.microsoft.com/en-us/nuget/nuget-org/overview-nuget-org#api-endpoint-for-nugetorg
There's also a similar question in the FAQ: https://learn.microsoft.com/en-us/nuget/resources/nuget-faq#i-don-t-see-nuget-org-in-my-list-of-repositories--how-do-i-get-it-back-

How to update Nuget tools-only packages via command line

Is it possible to update a "tools-only" Nuget package via the command line?
By "tools-only", I mean a package that does not contain a "lib" or "content" folder (according to the definition on the Nuget site), and contains scripts or tools rather than libraries that are referenced by Visual Studio Projects. A typical use is for tools that assist with build processes.
I am able to add tools-only packages in Visual Studio by managing the Nuget packages at the Solution level. That will download the package correctly, and also let me see and install updates to it.
But I've not been able to get the "update" command of the "nuget.exe" command line app to do the package update. It appears to drive all updates from the project files... but the package is not referenced by a project because it's not a code library.
I understand the focus of Nuget is code libraries, but the doco does make mention of tools packages... Given that it can be done within Visual Studio, I'd have thought the same should be possible on the command line.
E.g.
Tool package "A" (no lib, just tools folder)
In VS in project "B", manage Nuget packages on solution and install A
(Will download, and create ".nuget" folder with packages.config)
Release new version of "A"
In this scenario, I can see and install the update within VS, but cannot get the right command line to install the update.

Is there a nuget.exe command-line equivalent of Uninstall-Package?

I'm working on a NuGet package that installs a bunch of content - views, scripts, CSS files - into a web application, and trying to improve the change-compile-test cycle. I have two projects - the framework itself ("Package") and the demo web app that consumes it ("Website")
What I need to do as part of the Visual Studio build process is:
(as part of Package post-build) Nuget pack Package.nuspec -OutputDirectory ..\pkg\
(as part of Website pre-build) Nuget uninstall Package
(as part of Website pre-build) Nuget install package -source ..\pkg\
The problem is - there doesn't seem to be any command-line equivalent of doing Uninstall-Package from the NuGet Package Manager console. Am I missing something?
No there isn't currently.
Also, nuget.exe install doesn't really install anything. What nuget.exe install really does is nuget.exe restore: it restores the extracted package in the output directory. It doesn't run the PowerShell hooks (e.g. install.ps1) and it doesn't modify any target project (as there's none being targeted).
There is a way but using neither Visual Studio nor NuGet.exe. Using a custom build of SharpDevelop you can install and uninstall NuGet packages from the command line and have their PowerShell scripts run.
This custom build of SharpDevelop and its NuGet addin allows you to run the commands, such as Install-Package and Uninstall-Package, from PowerShell but outside of Visual Studio.
The limitations are that it needs SharpDevelop to be available and it also does not support any PowerShell scripts that are Visual Studio specific.

Nuget versioning issue with package restore

I am unable to install a package (using package restore) due to some kind of versioning issue with Nuget. Here are the steps I took:
build project:
error : The schema version of 'MagicalUnicorn.MvcErrorToolkit' is incompatible with version 1.6.21205.9031 of NuGet. Please upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942.
Extension manager says version is: 2.0.30619.9119.
Ok, restart VS as administrator, extension manager uninstall nuget.
restart VS as administrator again, search for nuget and install.
Extension manager again says version is: 2.0.30619.9119.
rebuild project:
error : The schema version of 'MagicalUnicorn.MvcErrorToolkit' is incompatible with version 1.6.21205.9031 of NuGet. Please upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942.
Ok, so restart VS as administrator, extension manager uninstall nuget again.
This time download from http://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c
Run the installer, all seems ok.
Extension manager again says version is: 2.0.30619.9119.
rebuild project:
error : The schema version of 'MagicalUnicorn.MvcErrorToolkit' is incompatible with version 1.6.21205.9031 of NuGet. Please upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942.
Grr! Any ideas?
It looks like problem in nuget command line tool. When you enable 'Nuget package restore' feature it adds .nuget folder to you solution with nuget.exe. And when you compile project this tool is using to download missing packages, not VS extension is used here. So try update this tool from command line:
cd .nuget
nuget.exe update -Self
Procedure screenshot:
The following worked for me in Visual Studio 2012:
Run VS 2012 as Administrator
Click Tools -- Extensions and Updates
In the left nav, Updates -- Visual Studio Gallery
Click Update on NuGet Package Manager
Install the update
Restart Visual Studio
None of the offered solutions worked for me (Visual Studio 2013, Nuget Package Manager Version 2.8.5).
I had same error but it was saying I had version 2.5.4.
I fixed it by going to Tools > Nuget Manager Console > Nuget Package Console. This open's up a command line window. At the top of the window was a prompt to download missing packages for my project.
Pressed the download button and errors went away upon build.
I was facing the same issue. I resolved it by selecting Tools on VS 2010 Menu --> Library Package Manager --> Package Manager Settings --> Check "Automatically check for updates". After that I restarted VS and was prompted for Nuget Update Installation. Once the update was installed, the Nuget package, HTTP Client in my case, got installed smoothly.
I faced to this problem and I checked all answers that were this page and at the end my problem did not solved. After lot of search on web I could update my nuget from original site
http://docs.nuget.org/docs/start-here/installing-nuget
and for example for vs2010 :
http://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c
At this site select your version of VS and then update it .
Note : before installing nuget,close all Visual Studios and after install,Open your project.
Thanks
This above did not work for me, completely. There is one last step that is IMPORTANT to note. After downloading the latest nuget version, you may notice that the same error prints in the output window. The reason is due to the .nuget folder containing a NuGet.exe which specifies a version number.
The solution (for me and perhaps to those of your that did not resolve your issue with the above directions), is to
Delete the .nuget folder from you solution.
Right click your web project and click Enable Nuget Restore.
The directions above should cause a NEW .nuget folder to be added, this time the NuGet.exe should be the newest version of nuget that you downloaded.

Reinstalling NuGet packages with NuGet installed as VS Extension

I would like to be able to install all of the NuGet packages in the packages.config, as per The NuGet docs. NuGet is installed as a VS Extension, and I can't seem to find nuget.exe. Is it possible to run:
nuget i packages.config -o Packages
Without maintaining a seperate copy of nuget.exe on a per project basis?
Reinstall all packages in all projects of the current solution:
Update-Package -Reinstall
You can find more information about reinstalling nuget packages here
Warning - using
Update-Package -Reinstall
or
Update-Package -Reinstall -IgnoreDependencies
may remove all of your packages and package.config files!
Always make sure that you have your backups performed first.
Scenario:
Solution with multiple projects
Each contains their own Nuget entries, some with the same packages (e.g., SharpRepository, Entity Framework)
Now copy folder without the packages folder for "distribution" somewhere else
Assume the packages folder wasn't included with the distribution
Now try the command Update-Package -Reinstall or if you have some alpha packages and/or are sure your dependencies are good, try Update-Package -Reinstall -IgnoreDependencies
Result:
Because the packages folder doesn't exist, the entries for your packages methodically go away, too. This can surprise some people - so be careful, is all I'm saying.
As an update to this post, NuGet 1.6 added support for the workflow to restore the packages at build time if missing.
Right-Click on the solution, click "Enable Package Restore Mode" to set it on.
More details at:
http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages
Found the solution on This blog entry. I needed to install NuGet.CommandLine, which makes nuget.exe. globally available in the VS command line. I can then set this up as a pre-build event to ensure that dependencies are downloaded.
A much easier option that you can keep enabled in Visual Studio during development to ease off your NuGet package installation related pain.
Keep both below mentioned options under NuGet Package Manager > General in checked state -
Allow NuGet to download missing packages
Automatically check for missing packages during build in Visual Studio
Have a look at the screenshot below:

Resources