Nuget批量上传

转载:https://blog.csdn.net/weixin_43609618/article/details/100120027

 

先上代码

 

@echo off
:: init params
set url=http://192.168.2.142:8081/repository/nuget-hosted/
set deployFile=*.nupkg
echo Searching nupkg file...
rem 启用"延缓环境变量扩充"
SETLOCAL ENABLEDELAYEDEXPANSION
for %%f in (%deployFile%) do (
   set name=%%f
   echo !name! to deploy to %url%
   rem deploy to server
   nuget push  !name!  ce65bd27-d98f-3db0-919d-ede38c3a68b7  -source  %url%  
)

pause

 

1、 在nexus设置security–>Realms 添加NuGet API-Key Realm

 

2、安装nuget(下载地址:https://dist.nuget.org/win-x86-commandline/latest/nuget.exe)
3、将上传的nuget包放到同一文件下

 

 4、获取nexus私服的NuGet API Key

可在点击admin账号,在新的页面点解NuGet API Key --> Access API Key

 

 5、修改uploadNugetPac.bat脚本文件,鼠标右键uploadNugetPac.bat编辑,上面的set url=填写hosted类型的nuget仓库,修改nuget push !name! ce65bd27-d98f-3db0-919d-ede38c3a68b7 -source %url%
将“!name!”后“-source”前的key替换为上一步获取的key,保存

 

 6、uploadNugetPac.bat脚本文件需放到需要上传的nuget包的目录下,双击即可上传
注意:若nuget.exe不是全局安装,则需在nuget.exe目录下进行上传文件;另外,已经上传过的nuget包,重新执行该批处理命令,会上传失败

 

posted @ 2020-11-17 08:50  嗨皮急死  阅读(345)  评论(0编辑  收藏  举报