发布自己的nuget包

1.下载nuget.exe

下载地址:https://dist.nuget.org/win-x86-commandline/latest/nuget.exe

或者 https://dist.nuget.org/

下载后不用安装,放到文件夹即可

2.添加nuget.exe的path路径,例如nuget.exe放在了D:Program Files uget文件夹中,在path中添加D:Program Files uget

3.建立一个类库项目,设置一下程序集信息

4.编译项目,最好debug和release都生成一下

5.cmd到项目文件夹(包含*.csproj的文件夹),执行命令nuget spec,生成*.nuspec文件

6修改*.nuspec文件,下面圈起来的建议修改,否则后面步骤可能报错

 7.生成nuget包,cmd执行nuget pack [项目名.csproj]

指定release版本生成命令:nuget pack 项目名.csproj -Prop Configuration=Release

8.注册账号 https://www.nuget.org/

注册后https://www.nuget.org/packages/manage/upload直接上传生成的*.nupkg包即可

9.或者生成apikey通过cmd命令上传

cmd中运行nuget setApiKey apikey -Source https://www.nuget.org/api/v2/package
apikey就是上面复制的apikey,Source是上传的服务器,如果是私有nuget服务器则使用私有服务的地址


参考:

发布自己的nuget包傻瓜教程

使用NuGet发布自己的类库包(Library Package)

Nuget发布属于自己的C#类库包

原文地址:https://www.cnblogs.com/wintertone/p/13650225.html