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

相关推荐
AI技术新视界15 分钟前
Qwen4-35B-A3B 已发布,社区第一波实测数据已出炉
服务器·人工智能·llm
中科米堆1 小时前
航空航天自动化 3D 尺寸检测方案|精密零部件三维扫描形位公差检测-CASAIM
运维·3d·自动化
Pin_Qing1 小时前
当旗舰模型挂上 Flash 的价签:MiniMax M4 的定价逻辑与工程账本
服务器·开发语言·网络·人工智能·程序人生
Huangjin007_1 小时前
【Linux 系统篇(四十四)】线程(五):线程互斥:从共享资源到互斥锁
linux·运维·服务器
xiangyun611 小时前
Ubuntu 网络排障决策树(5):SYN 到了网卡,为什么既没有 SYN-ACK 也没有 RST
linux·运维·服务器·网络·安全·ubuntu
CoderYanger1 小时前
Java EE 进阶:16. Spring原理(第二弹)
java·服务器·spring boot·后端·spring·面试·java-ee
持敬chijing2 小时前
网络安全设施运营1-防火墙概述
运维·网络·网络安全·系统安全
无忧.芙桃2 小时前
Linux系统编程(八):进程
linux·运维·服务器
wwj20242 小时前
跨地域经营企业HR平台选型:人才布局、权限治理与合规适配
java·运维·人工智能
中科米堆2 小时前
自动化三维尺寸测量工作站|制造业全尺寸形位公差自动检测方案-CASAIM
运维·自动化