美文网首页
6、Asp.net【c#】ItemDoc项目—NuGet发布打包

6、Asp.net【c#】ItemDoc项目—NuGet发布打包

作者: Net的搬运工 | 来源:发表于2018-06-10 15:46 被阅读110次

发布自己的类库包(Library Package)

NuGet是一个为大家所熟知的Visual Studio扩展,通过这个扩展,开发人员可以非常方便地在Visual Studio中安装或更新项目中所需要的第三方组件,同时也可以通过NuGet来安装一些Visual Studio的插件等。作为一名开发人员,您可能也会开发一些公共组件以供他人使用,本文将一步步介绍如何以最简单的方式将自己所开发的类库包发布到nuget上,以供更多的人使用。

如果你还是不知道什么是NuGet,那么你看什么教程啊

第一步

下载NuGet.exe,放到要打包发布的目录下。

https://www.nuget.org/downloads


第二步

配置NuGet.exe环境变量中,方便使用cmd命令。windows 我是直接放到了 C:\Windows\System32 简单省事不用配置变量。

配置成功之后的图片

第三步

进入目标目录 *.csproj 含有这个目录

E:\Item.Net-Common-Utility\Sop.Common.Serialization nuget spec

生成之后如下图


第三步骤图片

生成 Sop.Common.Serialization.nuspec

生成以下文件


生成结果图片

打开文档编辑下面的信息。

<?xml version="1.0"?>
<package >
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
    <projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
    <iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$description$</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2018</copyright>
    <tags>Tag1 Tag2</tags>
  </metadata>
</package>

第四步

编辑 Sop.Common.Serialization.nuspec

<?xml version="1.0"?>
<package >
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <licenseUrl>https://github.com/Sopcce/.Net-Common-Utility/blob/master/LICENSE</licenseUrl>
    <projectUrl>https://github.com/Sopcce/.Net-Common-Utility</projectUrl>
    <iconUrl>https://github.com/Sopcce/.Net-Common-Utility/blob/master/it.ico</iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$description$</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2018</copyright>
    <tags>net json</tags>
  </metadata>
</package>

编辑信息根据个人需要了。

第五步

nuget pack Sop.Common.Serialization.csproj

生成Sop.Common.Serialization.1.2.0.nupkg文件

生成 Sop.Common.Serialization.1.2.0.1.nupkg

第六步

https://www.nuget.org/packages/manage/upload

去上传 等一个小时之后,去vs 中搜下


上传文件之后信息

大约完成了,基本信息就完成。


<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <!-- 唯一的标识符 -->
    <id>Contoso.Utility.UsefulStuff</id>
    <!-- 版本号-->
    <version>$version$</version>
    <!--标题-->
    <title>$title$</title>
    <!-- 作者 -->
    <authors>$author$</authors>
    <!-- 拥有者。 nuget.org用户信息 -->
    <owners>$author$</owners>
    <!-- License  -->
    <licenseUrl>https://github.com/Sopcce/.Net-Common-Utility/blob/master/LICENSE</licenseUrl>
    <!--项目地址-->
    <projectUrl>https://github.com/Sopcce/.Net-Common-Utility</projectUrl>
    <!--图标在VisualStudio的包管理器UI中使用 -->
    <iconUrl>https://github.com/Sopcce/.Net-Common-Utility/blob/master/it.png</iconUrl>
    <!-- 如果为true,则此值提示用户何时接受许可证。安装软件包。 -->
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <!--关于这个特定版本的任何细节-->
    <releaseNotes>Bug fixes and performance improvements</releaseNotes>
    <!--该描述可用于包管理器UI。请注意Org.org画廊使用您在门户中添加的信息。  -->
    <description>$description$</description>
    <!-- Copyright information -->
    <copyright>Copyright ©2018</copyright>
    <!-- 标签出现在库中,可以用于标记搜索。 -->
    <tags>web utility http json url parsing</tags>
    <!-- Dependencies are automatically installed when the package is installed -->
    <dependencies>
      <dependency id="Newtonsoft.Json" version="9.0" />
    </dependencies>
  </metadata>

  <!-- A readme.txt to display when the package is installed -->
  <files>
    <file src="readme.txt" target="" />
  </files>
</package>

更多详细资料,去看官方中文文档了

https://docs.microsoft.com/zh-cn/nuget/what-is-nuget

相关文章

网友评论

      本文标题:6、Asp.net【c#】ItemDoc项目—NuGet发布打包

      本文链接:https://www.haomeiwen.com/subject/vnyfeftx.html