Fork me on GitHub

简单搭建 nuget 内部服务器

搭建 nuget 内部服务器,最好的方式是使用 ProGet,参考博文《用 ProGet 搭建内部的 NuGet 服务器》,好处非常多,但需要使用 SQL Server 数据库,如果不想使用数据库,相对来说,最简单的方式是使用NuGet.Server,网上教程一大堆,这边我做下自己的记录。

首先,VS 创建一个空的 ASP.NET 应用程序,然后 nuget 命令输入install-package NuGet.Server,接着会自动加载一些代码和文件,其中在 web.config 中会产生这样的配置:

<configuration>
  <appSettings>
    <!--
    Determines if an Api Key is required to push\delete 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="123456"/>
    <!--
    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"/>
  </appSettings>
<configuration>

其中最常用的是 apiKey 和 packagesPath,apiKey 是发布的 key,后面发布 nuget package 的时候会用到,packagesPath 是配置 package 的目录,默认目录是 ~/Packages。

nuget 内部服务器的发布和其他 ASP.NET 站点发布一样,直接发布在 IIS 上就可以了。

nuget package 的发布工具,可以使用 NuGet Package Explorer,下载地址:https://npe.codeplex.com

使用简单示例:

nuget package 发布完之后,就可以在项目中安装使用了,首先在 VS 中配置内部 nuget 服务器源,比如 http://10.10.10.10:8001/nuget,接下来就。。。

posted @   田园里的蟋蟀  阅读(1505)  评论(1编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
历史上的今天:
2015-08-11 ASP.NET 页面禁止被 iframe 框架引用
2014-08-11 Repository 仓储,你的归宿究竟在哪?(一)-仓储的概念
点击右上角即可分享
微信分享提示