在本机搭建私有NuGet服务器

写在前面

有时我们不想对外公开源码,同时又想在VisualStudio中通过Nuget包管理器来统一管理这些内部动态库,这时就可以在本地搭建一个NuGet服务器。

操作步骤

1.下载BaGet

这是一个轻量级的NuGet服务器

2.部署BaGet

将下载好的release版本BaGet解压至 C:\inetpub\wwwroot\BaGet

在IIS中新建应用程序池

新建网站,并指定BaGetAppPool 作为应用程序池,绑定域名 test.com

重点来了,修改BaGet站点下的 web.config 配置

XML 复制代码
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />      
      </handlers>
      <modules>
        <remove name="WebDAVModule"/>
        <remove name="WebDAV" />
      </modules>
      <aspNetCore processPath="dotnet" arguments=".\BaGet.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
    <system.webServer>
        <httpErrors errorMode="DetailedLocalOnly" />
    </system.webServer>
</configuration>

修改appsettings.json配置

javascript 复制代码
{
  "ApiKey": "ACMR",
  "Urls":"http://*:82",
  "PackageDeletionBehavior": "HardDelete",
  "AllowPackageOverwrites": true,
 
  "Database": {
    "Type": "Sqlite",
    "ConnectionString": "Data Source=baget.db"
  },
 
  "Storage": {
    "Type": "FileSystem",
    "Path": ""
  },
 
  "Search": {
    "Type": "Database"
  },
 
  "Mirror": {
    "Enabled": true,
    // Uncomment this to use the NuGet v2 protocol
    //"Legacy": true,
    "PackageSource": "https://api.nuget.org/v3/index.json"
  }, 
  "Logging": {
    "IncludeScopes": false,
    "Debug": {
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "Console": {
      "LogLevel": {
        "Microsoft.Hosting.Lifetime": "Information",
        "Default": "Warning"
      }
    }
  }
}

3.修改hosts 映射

C:\Windows\System32\drivers\etc\hosts

127.0.0.1 test.com

这样就可以在本地模拟通过域名来访问了。

运行示例

接下来把做好的nuget包 推上去就可以了。

相关推荐
x²+(y-√³x²)²=113 小时前
Linux打包文件到Windows,文件/文件类型丢失
linux·运维·windows
世人万千丶13 小时前
去重插入与超限淘汰:ArkTS 实现鸿蒙搜索历史的 LIMIT 艺术
运维·服务器·学习·华为·harmonyos·鸿蒙
未来之窗软件服务13 小时前
企业自动化运营-电子合同预览-东方仙盟
运维·自动化·仙盟创梦ide·东方仙盟
程序员与背包客_CoderZ13 小时前
Linux D-Bus通信协议详解:从入门到C/C++编码实战
linux·服务器·c语言·c++·嵌入式硬件·嵌入式软件·dbus
Android系统攻城狮13 小时前
Linux PipeWire深度解析之pw_properties_iterate调用流程与实战(六十五)
linux·运维·服务器·音频进阶·pipewire音频进阶
研华科技Advantech14 小时前
案例 | 从离线巡检到在线看护:研华PHM解决方案赋能石油钻井平台智能运维
运维·人工智能·边缘计算
難釋懷14 小时前
Nginx主动健康检查
运维·nginx
ITyunwei098714 小时前
内存溢出报错,实战处理记录
运维·服务器·企业微信
Elastic 中国社区官方博客14 小时前
你的 AI agent 不需要你的 API 密钥:使用 OAuth 2.1 对 Elasticsearch MCP 服务器进行身份验证
大数据·运维·人工智能·elasticsearch·搜索引擎·全文检索
FreeTinker15 小时前
AP AC组网中的远程运维挑战及内网穿透技术应用分析
运维