在本机搭建私有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包 推上去就可以了。

相关推荐
-今昭-13 小时前
MFS高可用负载均衡
运维·负载均衡
ITyunwei098713 小时前
SSL 证书过期排查实战:openssl + Nginx 4步从发现到续签
运维·网络
郝开13 小时前
Docker Compose 本地环境搭建:kkFileView
运维·docker·容器
QYR_1113 小时前
2032年气相分解设备市场规模达2.25亿美元:VPD向高灵敏度、自动化晶圆污染检测升级
运维·自动化
RisunJan13 小时前
Linux命令-vgchange(修改 LVM 卷组属性)
linux·运维·服务器
ZMacros14 小时前
Buildroot构建文件系统
linux·服务器
herinspace14 小时前
管家婆财贸ERP如何进行基本信息批量搬移
服务器·数据库·管家婆软件·财务软件
仓储管理员202514 小时前
不同业务场景下,如何匹配适配的WMS系统?
大数据·运维·云计算·精选
Είναι η κοπέλα14 小时前
游戏窗口自动化点击与防误点设计:模板匹配 + 区域限制 + 强制置顶
运维·游戏·自动化
六年码农14 小时前
2026最新开源 屏译ScreenTranslator 0.4.4 开源 全屏实时翻译教程
运维·人工智能·flutter·开源