Skip to content

baget

发表于
更新于
字数
阅读量

BaGet 是一个开源的 NuGet 服务器,旨在提供轻量级、高性能且易于部署的 NuGet 包管理解决方案。注:已不再更新,https设置容易出错。(ASPNETCORE_PATHBASE 是 ASP.NET Core 应用中一个至关重要但常被忽视的环境变量。它专门用于解决“应用运行在子路径(Sub-path)下”的场景。在没有设置 ASPNETCORE_PATHBASE 的情况下,ASP.NET Core 应用默认认为自己运行在域名的根目录 /

docker-compose配置

  baget:
    container_name: base-baget
    image: registry.cn-shenzhen.aliyuncs.com/shuze/baget:1.0
    ports:
      - "8025:80"
    environment:
      - ApiKey=SHUZE-NUGET-SERVER-API-KEY
      - Storage__Type=FileSystem
      - Storage__Path=/var/baget
      - Database__Type=Sqlite
      - Database__ConnectionString=Data Source=/var/baget/baget.db
      - Search__Type=Database
      - TZ=Asia/Shanghai
      - ASPNETCORE_PATHBASE=/baget #默认子目录
    volumes:
      - /root/baget:/var/baget
    restart: always

https解决方案

nginx配置


listen 443 ssl;
location ^~ /baget/ {
        proxy_pass http://baget;#/baget/
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
    location /v3/ {
        proxy_pass http://139.9.220.83:8225/v3/;
    }

nuget包

命令行输入dotnet nuget delete -s http://localhost:8020/v3/index.json xxx 1.0.0,就可以把服务器上的包删除掉,注意这里只写“包名 版本号”就行,“.nupkg”的后缀也不用加。

dotnet nuget delete -s https://shuze.net/v3/index.json  -k SHUZE-NUGET-SERVER-API-KEY Shuze.BaseService.Application 2.0.0

nuget包上传

dotnet nuget push -s https://shuze.net/v3/index.json  -k SHUZE-NUGET-SERVER-API-KEY .nupkg

vscode nuget源

https://shuze.net/baget/v3/index.json

删除包

命令行输入dotnet nuget delete -s http://localhost:8020/v3/index.json xxx 1.0.0,就可以把服务器上的包删除掉,注意这里只写“包名 版本号”就行,“.nupkg”的后缀也不用加。

https出错记录

BaGet-----------------https://shuze.net/baget/

vs中的源设置:
https://shuze.net/baget/v3/index.json //出错

https://shuze.net/v3/index.json  //nginx中把v3路径指向一下

    location /v3/ {
        proxy_pass http://120.79.58.102:8025/v3/;
     }

dotnet nuget push -s https://shuze.net/baget/v3/index.json -k SHUZE-NUGET-SERVER-API-KEY
Shuze.ClassLibrary.1.0.0.nupkg

包,application、application.contracts、domain、entityframeworkcore、domain.shared

云服务器迁移

需把原服务器baget整个目录下载后,再上传至新服务器对应目录

vscode中的Nuget设置,解决境外地址问题

NuGet.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <disabledPackageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    </disabledPackageSources>
    <add key="huawei" value="https://repo.huaweicloud.com/repository/nuget/v3/index.json" />
    <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
    <add key="azure" value="https://nuget.cdn.azure.cn/v3/index.json" />
    <add key="tencent" value="https://mirrors.cloud.tencent.com/nuget/" />
    <add key="shuze" value="https://shuze.net/baget/v3/index.json" />
  </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <packageManagement>
    <add key="format" value="0" />
    <add key="disabled" value="False" />
  </packageManagement>
</configuration>