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

相关推荐
应用市场17 分钟前
嵌入式Linux从裸板到产品(一):全景地图与交叉编译环境,从四个上板翻车现场说
linux·运维·服务器
CIMPro孪大师21 分钟前
CIMPro×DPE | 不止是爆炸动画,AI原生数字样机如何让设备培训与运维更高效
运维·ai-native
皓月盈江26 分钟前
Linux系统PC与Linux系统服务器通过scp上传与下载文件
linux·运维·服务器·scp·文件上传·文件下载
对讲机数码科普30 分钟前
危化厂区防爆专网通信建设实践:从合规框架到验收清单
运维·网络·架构
Ruiery39 分钟前
Linux 6.6内核 CPU 启动深度解析(二):AP 拉起 — BSP 如何用 INIT-SIPI 唤醒其余 CPU
linux·运维·服务器
Lsetea43 分钟前
OpenSSL verify报error 62:证书主机名不匹配与-verify_hostname排查
运维·https·ssl证书·openssl·san
rm -rf * && haha.sh1 小时前
【Linux】Rocky 9.8 操作系统磁盘分区与MySQL数据目录迁移
linux·运维·mysql
anew___1 小时前
《从零手写操作系统 (20):ELF加载器——让OS读懂现代编译器》
java·服务器·前端
吴声子夜歌1 小时前
Nginx应用与运维——Nginx Web服务应用实战(Python网站的搭建)
运维·前端·nginx
资深技术分享员2 小时前
Geejing WebBuilder 数据库连接配置与在线 SQL 工具,运维的左右手
运维·数据库·sql·低代码