将nuget包推送到Github包注册表:响应提前结束。发送请求时出错
我已经成功地设置了一个GitHub操作来构建和打包我的多目标NuGet包将nuget包推送到Github包注册表:响应提前结束。发送请求时出错,nuget,github-actions,github-package-registry,Nuget,Github Actions,Github Package Registry,我已经成功地设置了一个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: .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包()。这就是为什么我要构建一个步骤,并将文件复制到%cd%
推送到nuget.org的操作与预期一样,但推送到my github提要的操作失败,结果如下:
我查不出这里出了什么问题。有人知道为什么推动GitHub失败了吗
这里还有一个成功推送到GPR的示例,因此未提供API密钥的警告不是问题的原因:
()如果出现死链接:似乎现在,当您想将包推送到GitHub提要时,可以使用
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
或OutputPath
选项,因为对于多目标nuget软件包,这只会打包UWP目标DLL。也许可以尝试一下gpr push
工具,看看这是否有助于这里也有一些不同的方式推送到gpr(例如curl):.我已经阅读了这些方法,它们似乎过时了。例如,您不必生成令牌并将其放入secrets
,而是可以使用github.token
。此外,您不再需要使用dotnet numget add source
,而setup dotnet
操作将为您处理此问题。在我的情况下,唯一不起作用的是推送到Github包。它没有明确说明它无法验证请求,因此我怀疑这是否是问题所在……请检查项目中的发行说明。我以前也遇到过这样的情况,在标签packagereleaseenotes
中使用(,),“
等字符会导致包发布失败。我相信这与包的大小有关,请参见此处: