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

相关推荐
南工孙冬梅3 分钟前
Linux中安装配置nfs
linux·运维·php
中科岩创7 分钟前
云南某地光伏站边坡自动化监测服务项目
运维·人工智能·物联网·自动化
晚风吹人醒.14 分钟前
Linux系统安全及应用(账号权限管理、登录控制、弱口令、端口扫描)
linux·运维·系统安全·grub·sudo·账号管理
躲在云朵里`23 分钟前
Linux环境下部署SpringBoot前后端分离项目
linux·服务器
llilian_1624 分钟前
时间同步校时服务器配件清单及挑选攻略 校时时间服务器 网络时间同步装置
运维·服务器·网络
oMcLin24 分钟前
如何在Ubuntu 20.04系统的香港服务器上使用Docker搭建高效的CI/CD流水线并集成Kubernetes?
服务器·ubuntu·docker
nvd1130 分钟前
通过 Gmail API 发送邮件的完整指南
服务器·网络
深圳市恒讯科技32 分钟前
防止服务器被黑:终极防范网络攻击指南
运维·服务器·网络安全
VicdorLin33 分钟前
docker报错: client version 1.24 is too old. Minimum supported API version is 1.44
运维·docker·容器
橘颂TA34 分钟前
【Linux】从 “抢资源” 到 “优雅控场”:Linux 互斥锁的原理与 C++ RAII 封装实战(Ⅰ)
linux·运维·服务器·c++·算法