前言

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. 一小时包教会 —— webpack 入门指南

    什么是 webpack? webpack是近期最火的一款模块加载器兼打包工具,它能把各种资源,例如JS(含JSX).coffee.样式(含less/sass).图片等都作为模块来使用和处理. 我们可以 ...

  2. JavaScript面向对象之我见

    序言 在JavaScript的大世界里讨论面向对象,都要提到两点:1.JavaScript是一门基于原型的面向对象语言 2.模拟类语言的面向对象方式.对于为什么要模拟类语言的面向对象,我个人认为:某些 ...

  3. Python模拟HttpRequest的方法总结

    Python可以说是爬网的利器,本文主要介绍了一些python来模拟http请求的一些方法和技巧. Python处理请求的类库有两个,urllib,urllib2. 这两个类库并不是一个类库的两个不同 ...

  4. 《Entity Framework 6 Recipes》中文翻译系列 (10) -----第二章 实体数据建模基础之两实体间Is-a和Has-a关系建模、嵌入值映射

    翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 2-11 两实体间Is-a和Has-a关系建模 问题 你有两张有Is-a和Has-a ...

  5. rabbitMQ第五篇:Spring集成RabbitMQ

    前面几篇讲解了如何使用rabbitMq,这一篇主要讲解spring集成rabbitmq. 首先引入配置文件org.springframework.amqp,如下 <dependency> ...

  6. iOS 真机调试不能连接网络的排错过程

    开发环境: macOS 10.12.1 Xcode 8.1 Qt 5.8 gSOAP 2.8 iPhone 6S+iOS 10.1.1   问题: 使用 Qt Quick 写了一个跨平台的应用,在Wi ...

  7. Nginx配置文件nginx.conf详解

    #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_processes 8; #全局错误日志定义类型,[ debug | ...

  8. [汇编与C语言关系]1.函数调用

    对于以下程序: int bar(int c, int d) { int e = c + d; return e; } int foo(int a, int b) { return bar(a, b); ...

  9. [转]浏览器退出之后php还会继续执行么?

    原文链接:http://www.cnblogs.com/yjf512/p/5362025.html 前提:这里说的是典型的lnmp结构,nginx+php-fpm的模式 如果我有个php程序执行地非常 ...

  10. MVC实用架构设计(三)——EF-Code First(4):数据查询

    前言 首先对大家表示抱歉,这个系列已经将近一个月没有更新了,相信大家等本篇更新都等得快失望了.实在没办法,由于本人水平有限,写篇博客基本上要大半天的时间,最近实在是抽不出这么长段的空闲时间来写.另外也 ...