Cake build NuGetPush引发权限被拒绝

时间:2018-09-27 14:28:49

标签: .net-core travis-ci cakebuild

涉及到{p},我正在使用.NET Core脚本在Travis CI中构建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"

我尝试将- ./build.sh --Target="PushPackage"替换为- sudo bash build.sh --Target="PushPackage",但这无济于事。为什么我会收到此错误的任何建议?

build.sh文件是根据this构建的。整个仓库为here.

1 个答案:

答案 0 :(得分:1)

使用.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);
}