简体   繁体   中英

Powershell script to download package from NuGet

I want to set up a local repository for developers, this repository will be used to install packages on projects in our internal team. How can I setup local repository using powershell? Like-I want to provide 100(suppose) packages to my developers through my local repository. Manually, I've to download all those packages from Nuget.org into my local repository. This is the task I want to automate, I want powershell to take the name and download these packages from Nuget.org to my local folder.

Thanks.

ProGet has reasonably fine-grained permissions, including "pull" permissions (see https://inedo.com/support/documentation/proget/administration/security ).

I would suggest that that using a ProGet server to proxy NuGet.org, and only giving certain users "Add Package" and "Pull Package" privileges will give you the control you require with much less frustration.

Note that making a NuGet repository out of a network share can cause performance issues, especially when you start getting into the hundreds of NuGet packages. NuGet will end up having to download each file each time you want to do most of the standard commands.

I know this is old, but I was trying to find this solution too. RB's post gave me an idea and the missing piece was the -OutFile option.


Invoke-WebRequest -Uri $s -OutFile ("c:\\MyPackages\\$pn")

With $s = to the path of the package and $pn = to the whole package name as you want it saved as will download the package to the specified path.

I recently had to migrate 100's of packages and was able to automate the process them by iterating through the packages and using the command above to get each one and put them where needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM