我正在尝试通过 GitHub Actions 构建我的 dotnet 类库项目。除了一些标准的 nuget.org包之外,我的项目还使用存储在GPR上的私有 NuGet 包。我无法像在本地机器上那样成功构建。
我正在使用setup-dotnet
(并尝试过warrenbuckley/Setup-Nuget
,但没有运气):
jobs:
build:
runs-on: windows-latest # I started with ubuntu-latest, but the dotnet nuget is missing functionality.
steps:
- uses: actions/checkout@master
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.100'
source-url: https://nuget.pkg.github.com/owner/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- run: dotnet restore --source # fails here
- run: dotnet build -c Release --no-restore
我知道它找到了正确的 GPR,因为它在这里成功安装了我的私有包,但找不到任何 nuget.org pacakges。
我尝试过的另一个变体:
- run: dotnet nuget add source https://nuget.pkg.github.com/myorg/index.json -n "My Source"
- run: dotnet build -c Release --no-restore # fails here
在这里,它找不到我的私人包裹。
最近,我尝试了 nuget cli:
- uses: warrenbuckley/Setup-Nuget@v1
- run: nuget sources Add -Source https://nuget.pkg.github.com/myorg/index.json -Name "My Org" -username myorguser -password ${{secrets.GITHUB_TOKEN}} -StorePasswordInClearText
- run: nuget restore # Fails here
- run: dotnet build -c Release --no-restore
这提供了最多的信息,但仍然无法找到我的 GPR 包,尽管(与前面的示例不同)它找到了我期望的所有来源 (本地、nuget.org 和我的私人组织)。以下是一些看起来很有趣的日志:
32 NotFound https://nuget.pkg.github.com/myorg/download/mypackage/index.json
...
65 NotFound https://api.nuget.org/v3-flatcontainer/efinitycore/index.json
...
930 NU1101: Unable to find package MyPackage. No packages exist with this id in source(s): My Org, Microsoft Visual Studio Offline Packages, nuget.org
931 Errors in D:\a\WorkflowLibrary\WorkflowLibrary\WorkflowLibrary.Tests\WorkflowLibrary.Tests.csproj
932 NU1101: Unable to find package MyPackage. No packages exist with this id in source(s): My Org, Microsoft Visual Studio Offline Packages, nuget.org
...
935 NuGet Config files used:
C:\Users\runneradmin\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
C:\Program Files (x86)\NuGet\Config\Xamarin.Offline.config
942 Feeds used:
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
https://api.nuget.org/v3/index.json
https://nuget.pkg.github.com/myorg/index.json