Vs自定nuget push菜单

时间:2024-04-21 08:56:27

1 .net framework

需要准备 nuget.exe 和 nuget-push.cmd 命名行

nuget.ext 下载地址:https://files.cnblogs.com/files/liuxiaoji/nuget.zip

nuget 命令行

nuget push % -ApiKey localhostnuget -src http://www.localhostnuget.com/nuget/
-ApiKey 对应的key

-src  对应的地址
2 .net core
不需要nuget.exe
nuget 命令行
dotnet nuget push % -k loclhostnuge -s http://www.localhostnuget/nuget/

3.编辑VS

配置外部工具

Vs自定nuget push菜单

Vs自定nuget push菜单

配置自定义菜单

Vs自定nuget push菜单

Vs自定nuget push菜单

Vs自定nuget push菜单

右键项目属性设置nuget打包

Vs自定nuget push菜单

Vs自定nuget push菜单

右键项目先打包后推送

纯CMD推送

@echo off
::项目名称
set ProjectName=ProjectName
::Nuget发布的账号密码,中间用英文冒号隔开(account:password)
set ApiKey=account:password
::发布模式 Release/Debug
set PublishMode=Release
::Nuget发布地址
set SourceUrl=http://172.30.16.122/nuget/Default ::这里开始禁止修改
del %ProjectName%.*.nupkg /F /Q
nuget pack %ProjectName%.csproj -Build -Prop Configuration=%PublishMode%
nuget push "%ProjectName%.*.nupkg" -Source %SourceUrl% -ApiKey %ApiKey%
del %ProjectName%.*.nupkg /F /Q
pause

一键打包处理

外部命令设置

Vs自定nuget push菜单

批指令设置

@echo off
:: % 第一个参数变量 %~ 去掉变量中字符串的双引号
:: 项目路径
set ProjectDir=%~
:: 项目名称
set ItemFileNam=%~ ::字符串拼接 :: 打包文件头路径
set "Sender=%ProjectDir%%ItemFileNam%.csproj" ::nupkg包
set "NupkgPath=*.nupkg" ::Nuget发布的账号密码,中间用英文冒号隔开(account:password)
set ApiKey=localhostnuget
::发布模式 Release/Debug
set PublishMode=Debug
::Nuget发布地址
set SourceUrl= http://www.localhostnuget.com/nuget/ ::删除nuget包
del %NupkgPath% /F /Q ::生成程序包
nuget pack %Sender% -Build -Prop Configuration=%PublishMode%
::上传包
nuget push %NupkgPath% -Source %SourceUrl% -ApiKey %ApiKey%
::删除nuget包
del %NupkgPath% /F /Q pause

4.VS 使用配置

Vs自定nuget push菜单

Vs自定nuget push菜单Vs自定nuget push菜单