如何解决将nuget程序包推送到Github程序包注册表:响应过早结束发送请求时发生错误
我成功设置了一个GitHub操作,该操作构建并打包了我的多目标NuGet程序包。
name: .NET Core
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1.5.0
with:
dotnet-version: 3.1.301
# Authenticates packages to push to GPR
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
env:
NUGET_AUTH_TOKEN: '%NUGET_AUTH_TOKEN%'
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.0.1
- name: Install dependencies
run: msbuild /t:Restore
env:
NUGET_AUTH_TOKEN: ${{ github.token }}
- name: Build
run: msbuild /t:Pack /p:Configuration=Debug Library/MintPlayer.MVVM/MintPlayer.MVVM.csproj
- name: Copy
run: copy Library/MintPlayer.MVVM/bin/Debug/*.nupkg .
- name: PushNuget
run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.PUBLISH_TO_NUGET_ORG }} --skip-duplicate
- name: PushGithub
run: dotnet nuget push *.nupkg --no-symbols --skip-duplicate
env:
NUGET_AUTH_TOKEN: ${{ github.token }}
由于这是Xamarin.Forms包,因此我需要使用MSBuild SDK。
还原,构建和打包命令运行正常。我无法将p:OutputPath
参数用于多目标nuget程序包(Issue can be tracked here)。这就是为什么我要进行构建并将文件复制到%cd%
的原因。
推送到nuget.org的工作正常,但推送到我的github feed失败,结果如下:
我无法找出问题所在。有谁知道为什么推送到GitHub失败的原因?
这也是成功推送至GPR的示例,因此未提供API密钥的警告也不是问题的原因:
(Same question on github.community)
解决方法
万一链接失效:现在看来,当您要将包推送到GitHub feed时,可以使用nuget.exe
而不是dotnet nuget
来解决此问题。
name: .NET Core
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1.5.0
with:
dotnet-version: 3.1.301
# Authenticates packages to push to GPR
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
env:
NUGET_AUTH_TOKEN: '%NUGET_AUTH_TOKEN%'
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.0.1
- name: Install dependencies
run: msbuild /t:Restore
env:
NUGET_AUTH_TOKEN: ${{ github.token }}
- name: Build
run: msbuild /t:Pack /p:Configuration=Debug Library/MintPlayer.MVVM/MintPlayer.MVVM.csproj
#- name: Test
# run: dotnet test --no-restore --verbosity normal
- name: PushNuget
run: dotnet nuget push "**/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.PUBLISH_TO_NUGET_ORG }} --skip-duplicate
- name: PushGithub
run: nuget.exe push "**/*.nupkg" -NoSymbols -SkipDuplicate
env:
NUGET_AUTH_TOKEN: ${{ github.token }}
这似乎也修复了GPR被忽略的--skip-duplicate
标志。另外,请勿在您的步骤中使用p:OutputPath
或output-path
选项,因为对于多目标nuget程序包,它仅打包UWP目标DLL。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。