Cake 构建 NuGetPush 抛出权限被拒绝

Cake build NuGetPush throws permission denied

我正在构建我的 .NET Core app in Travis CI using Cake 脚本,当涉及到

var d = new DirectoryInfo(packageOutputPath.ToString());
var Files = d.GetFiles("*.nupkg").Select(x => new FilePath(x.FullName));

var key = EnvironmentVariable("NugetKey");

NuGetPush(Files, new NuGetPushSettings {
 Source = Variables.NugetSource,
 ApiKey = key

命令我得到:

An error occurred when executing task 'PushPackage'.
Error: One or more errors occurred. (Permission denied)
    Permission denied

我的 .travis.yml 文件:

sudo: required                

language: csharp              
mono: none                    
dotnet: 2.1.402               
before_install:
  - chmod +x build.sh         

script:
  - ./build.sh --Target="PushPackage"

我尝试用 - sudo bash build.sh --Target="PushPackage" 替换 - ./build.sh --Target="PushPackage" 但这没有帮助。我收到此错误的任何建议?

build.sh file was builded according to this. Whole repo is here.

您应该在使用 .NET CLI 时使用 DotNetCoreNuGetPush 别名,NuGetPush 需要 nuget.exe

示例:

DirectoryPath packageOutputPath = MakeAbsolute(Directory("./nuget/"));

var settings = new DotNetCoreNuGetPushSettings
{
     Source = "https://www.example.com/nugetfeed",
     ApiKey = "4003d786-cc37-4004-bfdf-c4f3e8ef9b3a"
};

foreach(var file in GetFiles($"{packageOutputPath}/*.nupkg"))
{
    DotNetCoreNuGetPush(file.FullPath, settings);
}