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

相关推荐
z落落28 分钟前
C# WinForm Socket 转串口设备服务器+Modbus CRC16校验+Socket 客户端
服务器·开发语言·c#
SkyWalking中文站7 小时前
SkyWalking 11 与 BanyanDB 0.11:在存储引擎内部实现 Trace 尾部采样
运维·监控·自动化运维
姚不倒7 小时前
etcd 学习系列(二):集群架构 —— 3 节点是如何工作的
运维·架构·etcd
pt10438 小时前
网络自动化Python课程:Cisco PyATS网络自动化测试框架
运维·自动化
小袁拒绝摆烂9 小时前
Jenkins部署经验
运维·jenkins
刚入门的大一新生9 小时前
Linux-进程控制
linux·运维·服务器·c++
上火的金鱼妹10 小时前
K8S基础组件作用和关系整理
linux·运维·服务器·kubernetes
Vcaker10 小时前
Linux学习25-harbor私有仓库部署
linux·运维·学习
醉颜凉10 小时前
网络安全必学:粘性MAC地址(Sticky MAC)原理与应用全解析
运维·服务器·网络·安全·web安全
不懂的浪漫11 小时前
ToDesk 连接 Linux 后分辨率过低的解决方法
linux·运维·数据库