简体   繁体   English

用于从 NuGet 下载包的 Powershell 脚本

[英]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?如何使用 powershell 设置本地存储库? Like-I want to provide 100(suppose) packages to my developers through my local repository.就像-我想通过我的本地存储库向我的开发人员提供 100 个(假设)包。 Manually, I've to download all those packages from Nuget.org into my local repository.我必须手动将所有这些包从 Nuget.org 下载到我的本地存储库中。 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.这是我想要自动化的任务,我希望 powershell 使用该名称并将这些包从 Nuget.org 下载到我的本地文件夹。

Thanks.谢谢。

ProGet has reasonably fine-grained permissions, including "pull" permissions (see https://inedo.com/support/documentation/proget/administration/security ). ProGet 具有合理的细粒度权限,包括“拉”权限(请参阅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.我建议使用 ProGet 服务器来代理 NuGet.org,并且只为某些用户提供“添加包”和“拉包”权限,这样您就可以获得所需的控制权,从而减少挫败感。

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 存储库可能会导致性能问题,尤其是当您开始使用数百个 NuGet 包时。 NuGet will end up having to download each file each time you want to do most of the standard commands.每次你想要执行大多数标准命令时,NuGet 最终都必须下载每个文件。

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. RB 的帖子给了我一个想法,缺少的部分是 -OutFile 选项。


Invoke-WebRequest -Uri $s -OutFile ("c:\\MyPackages\\$pn") 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.使用 $s = 指向包的路径,使用 $pn = 指向整个包名称,因为您希望将其保存为将包下载到指定路径。

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.我最近不得不迁移 100 个包,并且能够通过遍历包并使用上面的命令来获取每个包并将它们放在需要的地方来自动化处理它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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