Is there a way to get NuGet to update versions in package.config to the latest available?
i.e. is there an equivalent command in NuGet for npm's npm update --save/--save-dev?
Is there a NuGet command to update package.config versions?
You can use Update-Package on Package Manager Console window to update all packages to the latest version.
Alternatively, you can also use command with nuget.exe cli:
nuget update <configPath> [options]
where identifies either a packages.config or solution file that lists the project's dependencies.
Related
If I create a new Azure Functions project and do dotnet restore -v n with a cleared nuget cache, I see that it fetches (among others) the following packages from https://api.nuget.org/v3/index.json as transitive dependencies of Microsoft.NET.Sdk.Functions 4.1.1 (the only top-level package I have installed):
Installed Microsoft.AspNetCore.Http 2.1.0 from https://api.nuget.org/v3/index.json with content hash eAPryjDRH41EYY2sOMHCu+tHXLI6PUN1AsOPKst6GbiIoMi8wJCiPcE4h9418tKje1oUzmMc2Iz8fFPPVamfaw==.
Installed System.Net.Http 4.3.0 from https://api.nuget.org/v3/index.json with content hash sYg+FtILtRQuYWSIAuNOELwVuVsxVyJGWQyOnlAzhV4xvhyFnON1bAzYYC+jjRW8JREM45R0R5Dgi8MTC5sEwA==.
Installed System.Net.Sockets 4.3.0 from https://api.nuget.org/v3/index.json with content hash m6icV6TqQOAdgt5N/9I5KNpjom/5NFtkmGseEH+AK/hny8XrytLH3+b5M8zL/Ycg3fhIocFpUMyl/wpFnVRvdw==.
My question is why is it fetching these packages from nuget.org when they are part of the .net core SDK? Why is it not using those? Surely I am doing something wrong. Shouldn't the default be to use the packages from the SDK, not these old packages, some of which have vulnerabilities (System.Net.Sockets 4.3.0 for example)?
I'm not able to ignore these because we use a corporate JFrog repository that blocks these packages, so nuget restore errors when using that as a source. I'm showing the repro steps with nuget.org as the source to rule out an issue with JFrog. It also downloads (successfully) these old packages from nuget.org, so it can't be an issue with the repository. It must be something with my Visual Studio, nuget configuration, dotnet core installation, etc.
Check your Package Sources under Tools>Options>NuGet Package Manager.
If you uncheck the nuget.org it won't fetches packages from https://api.nuget.org/v3/index.json
It doesn't appear that the current dotnet CLI tools (1.0.1) support installing nugget packages from the command line (unless I'm missing something). Is there another way to install packages into a .Net Core 1.1 project other than by manually editing the .proj file?
dotnet add package adds a package reference to a project.
Find more information via dotnet add --help or dotnet add package --help.
If you lack that command, you might not be using the right version of the CLI.
> dotnet --version
1.0.1
Using team city as our CI and I've started getting this error message. We've obviously updated System.Net.Http recently which now needs a new version of NuGet. How do I get team city to find the new NuGet version. I've tried installing VS2015 and updating NuGet package manager through there. I've tried pointing directly to the command line nuget.exe (Don't know if that's been updated to v3?)
[restore] The 'System.Net.Http 4.0.0' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.60717.93'.
[restore] Process exited with code 1
Do I just have to just wait till MS pushing the new nuget package to nuget?
Thanks
On your teamcity client you can configure the nuget versions available to your build agents.
Go to Administration -> Integrations -> NuGet
From this screen you can click Fetch NuGet and retrieve the latest version. Then you should be able to specify that version on your build step.
Download NuGet 3.1 from this url:
http://dist.nuget.org/win-x86-commandline/v3.1.0-beta/nuget.exe
Then put that on your build server, put the directory in your path, and run your NuGet build steps as "Command Line" commands in TeamCity, using NuGet.exe.
I think you need TeamCity 9.1, as that version contains the VS2015 build tools: https://confluence.jetbrains.com/display/TCD9/What%27s+New+in+TeamCity+9.1
NuGet 3.0 was released with VS2015: http://docs.nuget.org/release-notes/nuget-3.0.0
In earlier versions of Visual Studio you could add a System reference to System.Net.Http, but Microsoft has now moved that into a NuGet package.
I recently installed Visual Studio on a new computer and as a result I now have Nuget 1.5.2. This version doesn't seem to work with my old solution. When I add a new project and try adding references via Nuget, it says they are already installed and does nothing, even though that reference doesn't exist in the new project.
Does anyone know why this might be happening or alternatively where I can download the old Nuget (1.4.2)?
Thanks!
The NuGet Command Line is available as a NuGet package.
Just like with any other NuGet package, you can get a specific version by using the -Version switch in the Package Manager Console.
To get v1.4.2 of the NuGet command line tool, you should execute the following PowerShell script from the Package Manager Console:
Install-Package Nuget.CommandLine -Version 1.4.20615.182
Is there a way to download a previous version of a package with NuGet, not the latest one?
Bring up the Package Manager Console in Visual Studio - it's in Tools / NuGet Package Manager / Package Manager Console. Then run the Install-Package command:
Install-Package Common.Logging -Version 1.2.0
See the command reference for details.
Edit:
In order to list versions of a package you can use the Get-Package command with the remote argument and a filter:
Get-Package -ListAvailable -Filter Common.Logging -AllVersions
By pressing tab after the version option in the Install-Package command, you get a list of the latest available versions.
Browse to its page in the package index, eg. http://www.nuget.org/packages/Newtonsoft.Json/4.0.5
Then follow the install instructions given:
Install-Package Newtonsoft.Json -Version 4.0.5
Alternatively to download the .nupkg file, follow the 'Download' link eg. https://www.nuget.org/api/v2/package/Newtonsoft.Json/4.0.5
Obsolete: install my Chrome extension Nutake which inserts a download link.
Another option is to change the version number in the packages.config file. This will cause NuGet to download the dlls for that version the next time you build.
In NuGet 3.x (Visual Studio 2015) you can just select the version from the UI
In NuGet 3.0 the Get-Package command is deprecated and replaced with Find-Package command.
Find-Package Common.Logging -AllVersions
See the NuGet command reference docs for details.
This is the message shown if you try to use Get-Package in Visual Studio 2015.
This Command/Parameter combination has been deprecated and will be removed
in the next release. Please consider using the new command that replaces it:
'Find-Package [-Id] -AllVersions'
Or as #Yishai said, you can use the version number dropdown in the NuGet screen in Visual Studio.
As the original question does not state which NuGet frontend should be used, I would like to mention that NuGet 3.5 adds support for updating to a specific version via the command line client (which works for downgrades, too):
NuGet.exe update Common.Logging -Version 1.2.0
I landed on this page but my requirement is different, I wanted to download old version of .nupkg file instead of downloading from VS2019 - to get old version of .nupkg
Go to nuget.org
Search package ex: Newton Json
Click on result package name
Click on Versions tab and download the version you want
By using the Nuget Package Manager UI as mentioned above it helps to uninstall the nuget package first. I always have problems when going back on a nuget package version if I don't uninstall first. Some references are not cleaned properly. So I suggest the following workflow when installing an old nuget package through the Nuget Package Manager:
Selected your nuget server / source
Find and select the nuget package your want to install an older version
Uninstall current version
Click on the install drop-down > Select older version > Click Install
Good Luck :)