前言

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. 细嗅Promise

    读完这篇文章,预计会消耗你 40 分钟的时间. Ajax 出现的时候,刮来了一阵异步之风,现在 Nodejs 火爆,又一阵异步狂风刮了过来.需求是越来越苛刻,用户对性能的要求也是越来越高,随之而来的是 ...

  2. 老司机学Xamarin系列总目录

    Xamarin开发环境及开发框架初探 Xamarin Forms开发框架二探 (Prism vs MvvmCross) Xamarin Forms开发框架之MvvmCross插件精选 Xamarin开 ...

  3. C# 用原生JS进行文件的上传

    1.此文章是用原生JS来进行文件的上传,有两个版本,一个不用ajax,一个用ajax. 1)非AJAX <!DOCTYPE html> <html> <head> ...

  4. Java抽象类的总结

    什么是抽象类: 当你在定义一个父级的类的时候,往往在父级内的方法没有添加任何内容,这时候如果你在子类里面调用父级的时候,万一在子类之中类名或者方法名没有写正确,会出现不执行的情况,但是这种情况默认是不 ...

  5. Android开发学习之路-Volley源码解析

    从简单的StringRequest入手看看Volley的工作机制. 先简单说下Volley的用法: ① 获取一个RequestQueue mRequestQueue = Volley.newReque ...

  6. NotSupportedException-无法将类型“System.DateTime”强制转换为类型“System.Object”

    几张图就可以说明一切 2015-03-29 21:54:09,206 [77] ERROR log - System.NotSupportedException: 无法将类型“System.DateT ...

  7. OpenCASCADE Quaternion

    OpenCASCADE Quaternion eryar@163.com Abstract. The quaternions are members of a noncommutative divis ...

  8. Python第一天 - set

    (一)初识set dict的作用是建立一组 key 和一组 value 的映射关系,dict的key是不能重复的.有的时候,我们只想要 dict 的 key,不关心 key 对应的 value,目的就 ...

  9. xUnit安装及注意事项

    前言 对于单元测试,想必大家都已再熟悉不过了,同时单元测试的重要性也越发突出,在招聘中也特别强调单元测试,但是对于微软内置的单元测试还是太过于繁琐,于是都在寻找一种简洁并且更加轻量的测试工具.用的最多 ...

  10. 浅析inline-block--使用inline-block创建布局

    inline-block前端程序猿们肯定不陌生,它是display属性的一个取值. 之所以称之为inline-block.是因为它兼具行内元素(inline-element)和块级元素(block-e ...