在本机搭建私有NuGet服务器

写在前面

有时我们不想对外公开源码,同时又想在VisualStudio中通过Nuget包管理器来统一管理这些内部动态库,这时就可以在本地搭建一个NuGet服务器。

操作步骤

1.下载BaGet

这是一个轻量级的NuGet服务器 

2.部署BaGet

将下载好的release版本BaGet解压至 C:\inetpub\wwwroot\BaGet

在IIS中新建应用程序池

 新建网站,并指定BaGetAppPool 作为应用程序池,绑定域名 test.com

重点来了,修改BaGet站点下的 web.config 配置

<?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配置

{
  "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包 推上去就可以了。

 

相关推荐

  1. Centos Git私有服务器

    2024-02-02 11:10:02       55 阅读
  2. Git篇如何自己服务器自己的git私有仓库

    2024-02-02 11:10:02       70 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-02 11:10:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-02 11:10:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-02 11:10:02       82 阅读
  4. Python语言-面向对象

    2024-02-02 11:10:02       91 阅读

热门阅读

  1. Centos Ubuntu 离线安装git

    2024-02-02 11:10:02       49 阅读
  2. c/c++ | 优先队列 | 大根堆、小根堆

    2024-02-02 11:10:02       55 阅读
  3. 【Cocos入门】AudioEngine函数的使用

    2024-02-02 11:10:02       55 阅读
  4. 免交互 、 字符处理与高级变量

    2024-02-02 11:10:02       38 阅读
  5. Django_项目基本配置

    2024-02-02 11:10:02       53 阅读
  6. LVS负载均衡对udp流量进行参数调整一例

    2024-02-02 11:10:02       48 阅读
  7. 使用Vue-Grid-Layout实现自定义工作台

    2024-02-02 11:10:02       51 阅读