前言

NuGet 是免费、开源的包管理开发工具,专注于在 .NET 应用开发过程中,简单地合并第三方的组件库。今天的目的就是记录一下如何打包一个类库,并发布到官网。在开始之前需要在www.nuget.org上注册一个账号,下载最新版本的nuget命令行工具https://dist.nuget.org/win-x86-commandline/latest/nuget.exe,并添加到环境变量中。

开始打包自己的类库

1.修改项目程序集信息AssemblyInfo.cs

我这里要打包的类库Zeroes.WeixinSDK来源于https://github.com/night-king/weixinSDK开源项目,修改完信息后重新生成一下。

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Zeroes.WeixinSDK")]
[assembly: AssemblyDescription("ZeroesSuit快速开发框架微信SDK库")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Zeroes")]
[assembly: AssemblyProduct("Zeroes.WeixinSDK")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("135e92df-8241-4d2c-97aa-910e1c53af81")] // Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.0.1")]
[assembly: AssemblyFileVersion("0.0.0.1")]

2.命令行下使用nuget spec命令生成Zeroes.WeixinSDK.nuspec打包配置文件

打开命令行定位到Zeroes.WeixinSDK项目所在目录,输入命令:nuget spec

修改生成的nuspec文件,内容如下:

<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
<projectUrl>http://www.cnblogs.com/zeroes</projectUrl>
<iconUrl>http://files.cnblogs.com/files/zeroes/Z.ico</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Zeroes.WeixinSDK封装了微信api的调用方法,可以方便的调用。</releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>Zeroes</tags>
</metadata>
</package>

3.打包类库

打开命令行定位到Zeroes.WeixinSDK项目所在目录,输入命令:nuget pack Zeroes.WeixinSDK.csproj

4.发布类库

登陆www.nuget.org网站,打开https://www.nuget.org/packages/manage/upload地址。

点击“Upload”上传后,显示信息确认页面,然后点击 “Submit”,发布完成,来张谍照:

5.使用nuget安装类库

参考文章:http://www.cnblogs.com/daxnet/archive/2013/05/07/3064577.html#3527602

最新文章

  1. maven 打包含有第三方依赖的 jar 包
  2. java.sql.SQLException: ORA-01000: 超出打开游标的最大数
  3. 安装mysql odbc遇到error 1918.errror installing ODBC driver mysql ODBC 5.3 ANSI Drive
  4. DICOM医学图像窗口变换的加速算法
  5. POJ 1016 模拟字符串
  6. 开源VS扩展CodeMaid介绍
  7. ASP.NET MVC:窗体身份验证及角色权限管理示例
  8. 以DDD为开发模式的设计开发步骤可以是
  9. 关于服务器响应,浏览器请求的理解以及javaWeb项目的编码问题
  10. IDEA中如何添加Scala插件。 我使用的IDEA版本是14
  11. 转:关掉Archlinux中烦人的响铃
  12. Discuz!图片查看插件(支持鼠标缩放、实际大小、旋转、下载)
  13. Android(java)学习笔记96:如何改变spinner系统自带的字体和颜色
  14. terminal命令
  15. text-overflow简单使用
  16. python学习day9
  17. 中文分词工具thulac4j正式发布
  18. 爬虫基础之urllib库(代码演示)
  19. Service工作原理
  20. 如何使用Wisdom RESTClient定制满足您个性化需求的API文档?

热门文章

  1. 如何让用户只能访问特定的数据库(MSSQL)
  2. MongoDB学习笔记~根据子集合里某个属性排序
  3. PHP类的封装和做投票和用进度条显示
  4. iOS 数据库的增删改查(OC版)
  5. 深入理解ajax系列第一篇——XHR对象
  6. floating IP 原理分析 - 每天5分钟玩转 OpenStack(107)
  7. 为什么更喜欢Outlook,而不是Gmail
  8. linux有关信号的FAQ
  9. 安装ClouderaManager以及使用ClouderaManager安装分布式集群的若干细节
  10. ModelState.IsValid总为false原因