当前位置:网站首页>Nuget 通过 dotnet 命令行发布
Nuget 通过 dotnet 命令行发布
2022-08-04 14:49:00 【林德熙】
在开发完成一个好用的轮子就想将这个轮子发布到 nuget 让其他小伙伴可以来使用,但是 nuget.org 的登陆速度太慢,本文介绍一个命令行发布的方法,通过命令行发布的方法可以配合 Jenkins 自动打包
本文不会告诉大家如何去制作一个 nuget 库,只是在大家已经打出来 nuget 之后如何将这个轮子发布到 nuget ,本文用 nuget.org 作为例子,如果是自己搭建的,那么我也不知道自己搭建的会做成什么
首先打开 nuget.org 进行登陆,就是因为登陆 nuget 实在太慢我才去学如何通过命令行的方法发布
登陆之后,可以在右上角看到自己的账号,点击一下可以看到下面界面,这时点击一个 Api key 因为在使用命令行发布的时候需要一个秘钥,通过上面的界面就可以创建秘钥
在 Api Key 界面可以看到 Create 这个按钮,没错,这是一个按钮
点击一下就可以创建一个 key 了,创建一个 key 可以给 key 不同的功能,具体请看下图
如果指定了可以修改版本的权限,可以设置有哪些轮子的版本号可以被这个 key 修改,请看下面
设置完成就可以点击 Create 了
创建之后需要复制这个 Key 的 序列,先将这个序列保存到文本,在之后会用到。注意,一个key只能在网页没关闭之前复制一次
本文使用的是设置了 MVVM 框架的三个轮子的更新权限,所以下面的例子就是更新一个轮子的版本
我通过 VisualStudio 编译出来不同的轮子的 nuget 请看图
然后我可以在地址栏输入 cmd 启动命令行,为什么需要在地址栏输入?原因是这样输入打开 cmd 就可以自动设置工作路径,请看下图,通过 cmd 打开的就是我需要的工作路径
这时可以通过下面的命令发布对应的 nuget 到 nuget.org 网站
dotnet nuget push xx.nupkg -k 刚才复制的key -s https://api.nuget.org/v3/index.json如我发布 lindexi.MVVM.Framework.2.2.5.symbols.nupkg 可以使用下面代码
dotnet nuget push lindexi.MVVM.Framework.2.2.5.symbols.nupkg -k oy2fvszjpukd6lm2vaqav5gcx6xcfuaencyx5x2ppab42e -s https://api.nuget.org/v3/index.json可以看到输出
info : Pushing lindexi.MVVM.Framework.2.2.5.symbols.nupkg to 'https://www.nuget.org/api/v2/package'...
info : PUT https://www.nuget.org/api/v2/package/
info : Created https://www.nuget.org/api/v2/package/ 12720ms
info : Your package was pushed.现在就成功发布了,那么用命令行除了减少在 nuget.org 登陆的时间之外,还可以用它做自动上传
可以通过这个方式在每次创建的时候只在文件夹保存一个 nuget 这样就可以通过命令行批处理的方式发布到 nuget 因为刚才的命令是可以支持任意的名字
上传某个文件夹内的 nuget 有一个要求就是这个文件夹内只有一个 nuget 不能有多个,而且上传的 nuget 的版本是不存在的,也就是不能多次上传相同版本号的 nuget 如果符合上面的条件就可以通过批处理的方式上传
在相同的文件夹创建一个 nuget.bat 文件,在这个文件输入下面代码
dotnet nuget push *.nupkg -k 刚才复制的key -s https://api.nuget.org/v3/index.json这样在编译之后调用这个批处理就可以将文件夹内的 nuget 上传,通过这个方式和 Jenkins 自动打包就可以自动发布 nuget 而且这个方式可以防止用户自己上传过程因为编译了不对的分支让其他用户以为自己写出坑
边栏推荐
猜你喜欢

Crawler - basic use of selenium, no interface browser, other uses of selenium, cookies of selenium, crawler cases

本周讨论用户体验:Daedalus 的 Nemo 加入 Ambire,探索加密海洋

基本介绍PLSQL

【 HMS core 】 【 Media 】 online video editing service 】 【 material can't show, or network anomalies have been Loading state

属于程序猿的浪漫

1403. 非递增顺序的最小子序列

Cisco-小型网络拓扑(DNS、DHCP、网站服务器、无线路由器)
![[The Art of Hardware Architecture] Study Notes (1) The World of Metastability](/img/ac/54e4e13d9df90e96933c69623b770e.png)
[The Art of Hardware Architecture] Study Notes (1) The World of Metastability

Kyushu Cloud attended the Navigator Online Forum to discuss the current status, challenges and future of 5G MEC edge computing

leetcode: 253. How many meeting rooms are required at least
随机推荐
[in-depth study of 4 g / 5 g / 6 g project - 50] : URLLC - 16 - the 3 GPP URLLC agreement, specification, technical principle of depth interpretation - 10 - high reliability technology - 1 - low codin
leetcode:241. 为运算表达式设计优先级
Technology sharing | Mini program realizes audio and video calls
B.构造一个简单的数列(贪心)
Bluetooth Technology|In the first half of the year, 1.3 million charging piles were added nationwide, and Bluetooth charging piles will become the mainstream of the market
数据库恢复
How to write SQL statements: the usage of Update, Case, and Select together
Crawler - action chain, xpath, coding platform use
爬虫——selenium基本使用、无界面浏览器、selenium的其他用法、selenium的cookie、爬虫案例
leetcode: 259. Smaller sum of three numbers
宣传海报
token 过期后,如何自动续期?
微软表示将向内部网络安全专家共享数据 为企业提供更安全保护
Centos7 install mysql version rapidly
I love Tanabata hahaha
[Problem solving] QT update component appears "To continue this operation, at least one valid and enabled repository is required"
[机缘参悟-60]:《兵者,诡道也》-1-开篇:“死“与“生“都是天道
手搓一个“七夕限定”,用3D Engine 5分钟实现烟花绽放效果
leetcode:215无序数组中找第k大的元素
杭电校赛(ACM组队安排)