使用BaGet快速搭建nuget服务

BaGet是基于 asp.net core编写的一个轻量级的 nuget管理服务,安装部署非常简单。

* Nuget版本号规范:https://learn.microsoft.com/zh-cn/nuget/concepts/package-versioning。

环境准备

  1. 下载 BaGet安装包。

    https://loic-sharma.github.io/BaGet/

  2. 下载 aspnetcore-runtime。

    https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/runtime-aspnetcore-3.1.32-windows-x64-installer

  3. 下载 dotnet-runtime。

    https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/runtime-3.1.32-windows-x64-installer

命令终端运行(自我寄宿)

  1. 解压 BaGet.zip

  2. 打开 cmd命令行,输入 dotnetBaGet.dll即可运行

以服务的方式运行

  1. 使用nssm进行安装,点击查看具体操作方法 (推荐)。

    https://blog.youkuaiyun.com/liyou123456789/article/details/123094277)

  2. 通过windows任务计划

相关配置

找到BaGet目录下的 appsettings.json配置文件。


{
  "ApiKey": "",
  //开启硬删除
  "PackageDeletionBehavior": "HardDelete",
  "AllowPackageOverwrites": true,

  "Database": {
    "Type": "Sqlite",
    "ConnectionString": "Data Source=baget.db"
  },

  "Storage": {
    "Type": "FileSystem",
    "Path": ""
  },

  "Search": {
    "Type": "Database"
  },

  "Mirror": {
    "Enabled": false,
    // Uncomment this to use the NuGet v2 protocol
    //"Legacy": true,
    //用于配置到visual studio中
    "PackageSource": "https://api.nuget.org/v3/index.json"
  },

  // Uncomment this to configure BaGet to listen to port 8080.
  //如果需要配置为Https,
  //"Https": {
  //      "Url": "https://*:5004",
  //      "Certificate": {
  //        "Path": "<path to .pfx file>",              (.pfx文件路径)
  //        "Password": "<certificate password>"          (证书密码)
  //          }
  //      }
  // See: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-3.1#listenoptionsusehttps
  
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://192.168.1.221:5000"
      }
    }
  },

  "Logging": {
    "IncludeScopes": false,
    "Debug": {
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "Console": {
      "LogLevel": {
        "Microsoft.Hosting.Lifetime": "Information",
        "Default": "Warning"
      }
    }
  }
}

配置Visual Studio中的Nuget配置

在Visual Studio 包管理器中,添加http://192.168.1.221:5000/v3/index.json 这样子的链接。IP地址可以根据实际部署的`IP`或者`域名`进行修改。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冷眼Σ(-᷅_-᷄๑)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值