前言

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

使用nuget打包类库并发布的更多相关文章

  1. 使用 Nuget打包类库

    使用 Nuget打包类库 NuGet是个开源项目,项目包括 NuGet VS插件/NuGet Explorer/NuGetServer/NuGet命令行等项目,.NET Core项目完全使用Nuget ...

  2. .NET Core 系列5 :使用 Nuget打包类库

    NuGet是个开源项目,项目包括 NuGet VS插件/NuGet Explorer/NuGetServer/NuGet命令行等项目,.NET Core项目完全使用Nuget 管理组件之间的依赖关系, ...

  3. Nuget打包类库及引用

    什么是nuget 适用于任何现代开发平台的基本工具可充当一种机制,通过这种机制,开发人员可以创建.共享和使用有用的代码. 通常,此类代码捆绑到"包"中,其中包含编译的代码(如 DL ...

  4. .NET Core 控制台项目中的Nuget打包类库及引用

    由于使用的是MAC版本的VSCode,所以全部是通过dotnet命令来完成的. 1.dotnet new lib 创建类库项目: 2.编辑项目根目录下的.csproj文件,添加版本号(建议): < ...

  5. 使用NuGet打包并发布至ProGet过程 (步骤详细,附python脚本)【上篇】

    一.基本知识 (1)NuGet : NuGet是一个为大家所熟知的Visual Studio扩展,通过这个扩展,开发人员可以非常方便地在Visual Studio中安装或更新项目中所需要的第三方组件, ...

  6. 【NuGet】使用NuGet打包并发布至ProGet过程 (步骤详细,附python脚本)【上篇】

    一.基本知识 (1)NuGet : NuGet是一个为大家所熟知的Visual Studio扩展,通过这个扩展,开发人员可以非常方便地在Visual Studio中安装或更新项目中所需要的第三方组件, ...

  7. 使用NuGet打包并发布至ProGet过程 (打包再次详解)【下篇】

    一.前言 上篇[1]主要介绍了利用csproj文件使用NuGet打包至ProGet的过程,并附上了用于在Jenkins上运行的python脚本.本篇的主要内容分为以下几点: 1. Nuspec与Nup ...

  8. 【NuGet】使用NuGet打包并发布至ProGet过程 (打包再次详解)【下篇】

    一.前言 上篇[1]主要介绍了利用csproj文件使用NuGet打包至ProGet的过程,并附上了用于在Jenkins上运行的python脚本.本篇的主要内容分为以下几点: 1. Nuspec与Nup ...

  9. Nuget~打包时添加powershell初始化脚本

    对于进行nuget打包时,有时我们需要添加一个配置文件,就是一些文本文件,而这些文件我们在网站发布时需要同时复制到输出目录,否则会出现文件丢失的问题,我们在打包时通过添加powershell脚本来解决 ...

随机推荐

  1. Python黑帽编程2.3 字符串、列表、元组、字典和集合

    Python黑帽编程2.3  字符串.列表.元组.字典和集合 本节要介绍的是Python里面常用的几种数据结构.通常情况下,声明一个变量只保存一个值是远远不够的,我们需要将一组或多组数据进行存储.查询 ...

  2. 《R in Action》读书笔记(1)

    MindMapper 原文件

  3. C#设计模式之外观

    IronMan之外观 接着上篇观察者内容的“剧情”,没看过的朋友也没关系,篇幅之间有衔接的关系但是影响不大. 需求: 为"兵工厂"提供各种支持,生产了各式各样的"Iron ...

  4. JavaScript实现TwoQueues缓存模型

    本文所指TwoQueues缓存模型,是说数据在内存中的缓存模型. 无论何种语言,都可能需要把一部分数据放在内存中,避免重复运算.读取.最常见的场景就是JQuery选择器,有些Dom元素的选取是非常耗时 ...

  5. 2013 duilib入门简明教程 -- 自绘标题栏(5)

        如果大家有做过标题栏的自绘,肯定会感慨各种不容易,并且现有的一些资料虽然完美的实现了功能,但是代码比较乱,需要自行整理.如果用duilib,就是小case啦.     duilib其实并没有区 ...

  6. MVC validate.js下使用 ajaxSubmit

    首页定义验证实体 using System.ComponentModel.DataAnnotations; using System.Web.Mvc; namespace MvcApplication ...

  7. XE2:查看Extended Events收集的数据

    SQL Server 使用Target来存储Events,Target 能够将Events存储到File中(扩展名是 xel),或 memoy buffer 中(Ring Buffer),Event ...

  8. Caffe学习笔记1--Ubuntu 14.04 64bit caffe安装

    本篇博客主要用于记录Ubuntu 14.04 64bit操作系统搭建caffe环境,目前针对的的是CPU版本: 1.安装依赖库 sudo apt-get install libprotobuf-dev ...

  9. MVC4做网站后台:栏目管理2、修改栏目

    接上节添加栏目. 修改栏目与添加栏目非常相似,主要区别在于先向视图传递要修改栏目的model.另外在保存时比添加栏目验证要更多一些. 1.要验证父栏目不能是其本身: 2.父栏目不能是其子栏目: 3.父 ...

  10. ScrollView 嵌套ListView、RecyclerView(持续更新)

    ListView: 只要重写ListView或GridView的onMeasure()方法即可: @Override protected void onMeasure(int widthMeasure ...