下载地址:https://www.nuget.org/downloads
创建一个Key
Key Name 和 Glob Pattern 名称一样就好
创建完成后点击copy,保存起来。因为以后无法再次复制密钥!!!
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools
双击运行 Developer Command Prompt for VS 2019
cd到类库的目录
通过命令 nuget setapikey xxxxx-xxxx-xxx-xxxx-xxxx-xxxx , 设置API Key;
nuspec是NuGet将项目打包成nupkg的输入文件,可以通过nuget spec命令产生。
通过命令 nuget spec 生成xxxx.nuspec文件;
用记事本打开NugetTest.nuspec文件
注意里面的$xxx$宏,这些就是引用了AssemblyInfo.cs中的设置值,在编译产生package的时候,会使用AssemblyInfo.cs中的相应值进行替换。完成编辑后,我们的nuspec文件如下:
通过命令 NuGet pack xxxxxx.csproj 生成xxxx.nupkg文件
通过命令 nuget.exe push xxxxx.nupkg -Source https://www.nuget.org ,将NuGet发布到服务器。
参考文档:https://docs.microsoft.com/zh-cn/nuget/quickstart/create-and-publish-a-package-using-the-dotnet-cli
翻译:https://www.cnblogs.com/chuankang/p/10076082.html
微信公众号:net分享
原文:https://www.cnblogs.com/netcore5/p/14738764.html