ChatGPT解决这个技术问题 Extra ChatGPT

How to download a Nuget package without nuget.exe or Visual Studio extension?

How can I download a NuGet package? I don't have the NuGet Visual Studio extension or the command line program nuget.exe. How can I download the .nupack file from the web? As I understand I will be able to extract the .dll files from it (with 7-zip) to use as normal.

The package I happen to be interested in is http://nuget.org/packages/Microsoft.Bcl.Async, but I would like to know how to do this generally.

In the world of Ruby this would be easy - every package page on the RubyGems website has a download link to a .gem file, e.g.: https://rubygems.org/gems/pony

The argument over NuGet's manifest destiny belongs elsewhere. It doesn't matter to this question why I eschew it. I'm not the only one though.

@JonSkeet: My development system is not connected to the internet (for security reasons) except by using a Windows Terminal Server session. This WTS does allow downloads, but I cannot start executeables, so there is no (convenient) way for me to get stuff that's only available via nuget (at least whilst at work, anyway).

C
Colonel Panic

Either make an account on the Nuget.org website, then log in, browse to the package you want and click on the Download link on the left menu.

Or guess the URL. They have the following format:

https://www.nuget.org/api/v2/package/{packageID}/{packageVersion}

Then simply unzip the .nupkg file and extract the contents you need.


Thanks Xavier, that worked. For the library I wanted it was nuget.org/api/v2/package/Microsoft.Bcl.Async/1.0.14-rc
If you just want the latest package, simply leave the /{packageVersion} part out.
@Muds You'll have to parse the nuspec and download the listed dependences yourself.
This answer still works, but is outdated. See below: stackoverflow.com/a/32681762/2642204
How to download package dependencies?
q
quasoft

Although building the URL or using tools is still possible, it is not needed anymore.

https://www.nuget.org/ currently has a download link named "Download package", that is available even if you don't have an account on the site.

(at the bottom of the right column).

Example of EntityFramework's detail page: https://www.nuget.org/packages/EntityFramework/: (Updated after comment of kwitee.)

https://i.stack.imgur.com/Szkjr.png


FYI, you can definitely use 7-zip to extract and it'll handle .nupkg filetype, but since they are just .zip files under the hood, you can also just change the extension to .zip and browse/unzip as needed.
Just be aware that you'll have to download any dependent packages manually if you go this route.
Or else trigger "nuget install" and look for URL used in verbose mode...
M
Marcello Miorelli

Based on Xavier's answer, I wrote a Google chrome extension NuTake to add links to the Nuget.org package pages.


B
BartoszKP

To obtain the current stable version of the NuGet package use:

https://www.nuget.org/api/v2/package/{packageID}

M
MJ Vakili

I haven't tried it yet, but it looks like NuGet Package Explorer should be able to do it:

https://github.com/NuGetPackageExplorer/NuGetPackageExplorer

https://i.stack.imgur.com/0kRXQ.png

(or like Colonel Panic says, 7-zip should probably do it)


Yes, it works fine. Just use the "Open from Feed..." option.
M
Mehdi Kashefikia

Go to http://www.nuget.org Search for desired package. For example: Microsoft.Owin.Host.SystemWeb Download the package by clicking the Download link on the left. Do step 3 for the dependencies which are not already installed. Store all downloaded packages in a custom folder. The default is c:\Package source. Open Nuget Package Manager in Visual Studio and make sure you have an "Available package source" that points to the specified address in step 5; If not, simply add one by providing a custom name and address. Click OK. At this point you should be able to install the package exactly the same way you would install an online package through the interface. You probably won't be able to install the package using NuGet console.


S
Semi

Don't know if this is what you want, but here it is:

Download nuget.exe (∼6.5MB, no install required) from the official NuGet site: https://www.nuget.org/downloads In CLI type following to retrieve list of available packages: nuget.exe list -source Then download the package by typing this: nuget.exe install -source -OutputDirectory

Contents of the downloaded package are the .nupkg file, .dll files for x86 and x64 as well as .props and .targets files. BTW: .nupkg can be opened as a .zip file.