zoukankan      html  css  js  c++  java
  • 【ASP.NET】利用Nuget打包package——命令行方式

    通过命令行

    官方说明,可以参考:creating-and-publishing-a-package
    如果你希望可以使用图形界面的方式,请参考这篇文章
     
    打包dll
     
    使用如下的命令:
    nuget spec MyAssembly.dll
    会生成MyAssessmbly.nuspec文件,与GUI方式中选择Edit Metadata生成的xml文件一致。
     
    打开*.nuspec文件,可以看到结构如下的文件
    <?xml version="1.0"?>
    <package >
      <metadata>
        <id>StoShared.NHibernate.dll</id>
        <version>1.0.0</version>
        <authors>rentu</authors>
        <owners>rentu</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>Package description</description>
        <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
        <copyright>Copyright 2016</copyright>
        <tags>Tag1 Tag2</tags>
        <dependencies>
          <dependency id="SampleDependency" version="1.0" />
        </dependencies>
      </metadata>
    </package>


    根据需要,修改相应的配置属性,修改完成后,使用下面的命令进行打包
    nuget pack MyAssembly.nuspec
    注意,dll需要放到lib文件夹下,才会在install package后被自动添加引用。在lib文件夹下建立类似net40文件夹,可以保证package在.net 4.0上运行。
     
     
    打包项目
    在项目的根文件夹下(包含csproj的文件夹下,使用如下的命令)
    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://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 2016</copyright>
        <tags>Tag1 Tag2</tags>
      </metadata>
    </package>


    其中的一些通配符,会在我们打包的时候,根据项目的配置文件自动替换,替换规则如下表所示。
     
    Token Source
    $id$ The Assembly name
    $version$ The assembly version as specified in the assembly’sAssemblyVersionAttribute (orAssemblyInformationalVersionAttribute if present).
    $author$ The company as specified in the AssemblyCompanyAttribute.
    $description$ The description as specified in the AssemblyDescriptionAttribute.
     
    默认情况下,打包package只会包含编译生成的dll文件和lib文件夹下的文件,可以通过下面的配置添加其他需要的文件。
     
    <files> <filesrc="....SomeRoot***.*" target=""/> </files>


     
    编辑好后,通过下面的命令进行打包
    nuget pack MyProject.csproj
     
    可以有以下的参数:
    nuget pack A.csproj -IncludeReferencedProjects  打包时包含引用的项目
    nuget pack MyProject.csproj -Prop Configuration=Release 打包release的dll
     最新博客地址:http://blog.turenlong.com/
  • 相关阅读:
    1107 Social Clusters (30分)
    1108 Finding Average (20分)
    1109 Group Photo (25分)
    js-字符串(String)方法大全
    js-数组(Array)方法大全
    js-产生随机验证码的具体案例
    js-事件细节详解以及案例
    js-数据类型转换(强制转换、隐式转换)和数据运算符(包含三目运算符)详解
    css3-文本阴影(text-shadow)和盒子阴影(box-shadow)详解及其案例
    css3-动画animation详解及其案例
  • 原文地址:https://www.cnblogs.com/reachteam/p/5768676.html
Copyright © 2011-2022 走看看