zoukankan      html  css  js  c++  java
  • 转载:图解搭建公司内部的NuGet Server

    NuGetServer 搭建和配置

    1.  

      创建一个 “NuGetServerSolution” 解决方案,然后新增 “NuGetServer” Asp.Net 网站 或者 应用程序 空 项目。结构如下图所示:

      图解搭建公司内部的NuGet Server
    2.  

      在 “NuGetServer” 项目上,右键选择 “管理NuGet程序包” ,选择 “联机” ,右上角搜索框中输入“NuGet.Server”  Enter,在搜索结果中选择 NuGet.Server 项,进行安装,如下图所示:

      注意:如果安装最后,提示 替换 Web.config ,请选择“全是”。

      图解搭建公司内部的NuGet Server
    3.  

      编译“NuGetServer”项目,如果没有出异常,这里就创建项目完成,NuGetServer 就这么简单建成,稍后我部署到IIS上面,看看是不是真的可以了,先来讲一下这个网站WebConfig 要配置地方。

      <?xml version="1.0" encoding="utf-8"?>

      <!--

        For more information on how to configure your ASP.NET application, please visit

        http://go.microsoft.com/fwlink/?LinkId=169433

        -->

      <configuration>

        <appSettings>

          <!--

          Determines if an Api Key is required to pushdelete packages from the server. 

          -->

          <add key="requireApiKey" value="true" />

          

          <!-- 

          Set the value here to allow people to push/delete packages from the server.

          NOTE: This is a shared key (password) for all users.

          -->

          <add key="apiKey" value="0226651E-19EE-4F93-A172-5250C84DB16C" />

          

          <!--

          Change the path to the packages folder. Default is ~/Packages.

          This can be a virtual or physical path.

          -->

          <add key="packagesPath" value="" />

          <!--

          Set allowOverrideExistingPackageOnPush to false to mimic NuGet.org's behaviour (do not allow overwriting packages with same id + version).

          -->

          <add key="allowOverrideExistingPackageOnPush" value="false" />

          <!--

          Set ignoreSymbolsPackages to true to filter out symbols packages. Since NuGet.Server does not come with a symbol server,

          it makes sense to ignore this type of packages. When enabled, files named `.symbols.nupkg` or packages containing a `/src` folder will be ignored.

          

          If you only push .symbols.nupkg packages, set this to false so that packages can be uploaded.

          -->

          <add key="ignoreSymbolsPackages" value="true" />

          

          <!--

          Set enableDelisting to true to enable delist instead of delete as a result of a "nuget delete" command.

          - delete: package is deleted from the repository's local filesystem.

          - delist: 

            - "nuget delete": the "hidden" file attribute of the corresponding nupkg on the repository local filesystem is turned on instead of deleting the file.

            - "nuget list" skips delisted packages, i.e. those that have the hidden attribute set on their nupkg.

            - "nuget install packageid -version version" command will succeed for both listed and delisted packages.

              e.g. delisted packages can still be downloaded by clients that explicitly specify their version.

          -->

          <add key="enableDelisting" value="false" />

          <!--

          Set enableFrameworkFiltering to true to enable filtering packages by their supported frameworks during search.

          -->

          <add key="enableFrameworkFiltering" value="false" />

          

          <!--

          When running NuGet.Server in a NAT network, ASP.NET may embed the erver's internal IP address in the V2 feed.

          Uncomment the following configuration entry to enable NAT support.

          -->

          <!-- <add key="aspnet:UseHostHeaderForRequestUrl" value="true" /> -->

        </appSettings>

        <system.web>

          <httpRuntime maxRequestLength="31457280" />

          <compilation debug="true" />

        </system.web>

        <system.serviceModel>

          <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

        </system.serviceModel>

        <system.webServer>

          <staticContent>

            <mimeMap fileExtension=".nupkg" mimeType="application/zip" />

          </staticContent>

          <modules runAllManagedModulesForAllRequests="true">

          </modules>

        </system.webServer>

      </configuration>

      第一点: 程序包发布,存放的路径,在WebConfig appSettings PackagesPath 这个Key 设置,默认存放在部署的网站根目录Packages文件夹。

      第二点:appSettings requireApiKey 这个key 如果设置成 true , appSettings  apiKey 是必须要设置的,这个就像密码一样。可以阻止不知道这个apiKey人访问到程序包

    4.  

      部署到IIS, 打开IIS ,右键选择  “网站”  ,添加网站,填写 网站名称(NuGetServer),选择物理路径,端口号 改成 "1000" 确定, 如下图所示:

      图解搭建公司内部的NuGet Server
    5.  

      运行 NuGetServer 网站 "http://localhost:1000/", 出现下图效果,则说NuGet 服务器 已经建立完成。

    6.  

      接着配置Visual Studio 连接 NuGetServer。选择“工具”菜单,选择“选项”,弹出“选项”界面,选择 “NuGet Package Manager” ,然后在选择 “程序包源”,

      点击 “+”,在界面下方 设置 名称 “mynuget.org” 随便取,设置 源 “http://localhost:1000/nuget” (是不是上图有说),确定 关闭界面,回到项目。如下图

      图解搭建公司内部的NuGet Server
    7. 7

      在项目右键,选择“管理NuGet程序包”,联机,下面是不是多出了一个 “mynuget.org” 程序源呢,虽然下面还没有发布公司内部的程序包。如下图所示:

      图解搭建公司内部的NuGet Server
    8. 8

      到此,NuGetServer 服务器,就搭建并配置完成。接一下来就是如何发布程序包,以及安装程序包了。

      END

    发布程序包,以及安装程序包

     
    1. 1

      NuGet Package Explorer

      将程序包发布到NuGetServer,还要介绍到另外一个工具“NuGet Package Explorer”,这个工具是NuGetServer 程序包一个可视化的工具,它功能很多,可浏览已经发布的程序包信息,可以发布新的程序包(设置程序包版本,已经依赖程序包等),可以删除发布的程序包。

      CodePlex:https://npe.codeplex.com/

      GitHub:https://github.com/NuGetPackageExplorer

    2. 2

      在CodePlex 网站上,下载  NuGet Package Explorer , 安装完成后,桌面会多出一个 “NuGet Package Explorer” 图标,如下图所示:

      图解搭建公司内部的NuGet Server
    3. 3

      为了方便Demo,再创建一个 解决方案 “NuGetServerDemoSolution”,添加“NuGetServerDemo” 控制台项目,再添加 “NuGetServerDemoDLL” 类库项目,结构如下图所示:

      “NuGetServerDemoDLL” 项目 主要会做成程序包发布

      “NuGetServerDemo” 项目 安装“NuGetServerDemoDLL” 程序包

      图解搭建公司内部的NuGet Server
    4. 4

       打开 桌面 “NuGet Package Explorer” ,界面如下图所示:

      图片选项, 分别意思是:

      1. 打开本地的nupkg,nuspec 文件。

      2. 打开指定 NuGetServer 所有的程序包列表。

      3.创建一个新程序包。

      4. 文档

      图解搭建公司内部的NuGet Server
    5. 5

      把 “NuGetServerDemoDLL” 发布到NuGetServer,点 “Create  a new package” 未设置前截图如下图所示:

      上图分为两个编辑区,一个是 Package Metadata 负责描述程序包信息的,Package Contents 负责程序包文件相关的。

      点击   Package Metadata 区 “编辑” 按钮,想编辑 “NuGetServerDemoDLL”  程序包描述信息。

      图解搭建公司内部的NuGet Server
    6. 6

      然后 将“NuGetServerDemoDLL” 项目 产生Dll,拖入 Package Contents   最后效果如下图所示:

      图解搭建公司内部的NuGet Server
    7. 7

      点击 上图 绿色的 √ 关闭编辑Package Metadata , 点击 ”File“ 菜单,选择 Publish 发布程序集,填写 PublishUrl(NuGetServer),PublishKey(apiKey),填写完成 点击“Publish” 发布,如果下方提示 “Package published successfully”,则发布成功。如下图所示:

      图解搭建公司内部的NuGet Server
    8. 8

      回到“NuGetServerDemoSolution” 解决方案,右键“NuGetServerDemo”,选择“管理NuGet程序包”,选择联机下“mynuget.org”,安装“NuGetServerDemoDLL” 程序包,如下图所示:

      主要看图左边的 ,是不是“NuGet Package Explorer” 中设置过的一些程序包信息。

      图解搭建公司内部的NuGet Server
    9. 9

      用“NuGet Package Explorer”查看 NuGetServer 以发布程序包,选择“File”菜单,选择"Open from feed", 就会查询到指定 NuGetServer 发布程序包,如下图所示:

      图解搭建公司内部的NuGet Server
  • 相关阅读:
    Javascript高级编程学习笔记(32)—— 客户端检测(1)能力检测
    Javascript高级编程学习笔记(31)—— BOM(5)screen、history对象
    Javascript高级编程学习笔记(30)—— BOM(4)navigator对象
    Javascript高级编程学习笔记(29)—— BOM(3)location对象
    Javascript高级编程学习笔记(28)—— BOM(2)window对象2
    Javascript高级编程学习笔记(27)—— BOM(1)window对象1
    逆向与反汇编工具
    Silicon Labs
    sk_buff 里的len, data_len, skb_headlen
    IP分片重组的分析和常见碎片攻击 v0.2
  • 原文地址:https://www.cnblogs.com/yuanshou/p/10345614.html
Copyright © 2011-2022 走看看