0

I'm building my .NET Core app in Travis CI using Cake script, when it comes to

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

command I get:

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

My .travis.yml file:

sudo: required                

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

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

I have tried replacing - ./build.sh --Target="PushPackage" with - sudo bash build.sh --Target="PushPackage" but this did not help. Any suggestions why I'm getting this error?

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

Carlos28
  • 2,381
  • 3
  • 21
  • 36

1 Answers1

1

You should be using the DotNetCoreNuGetPush alias when using the .NET CLI, NuGetPush requires nuget.exe.

Example:

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);
}
devlead
  • 4,935
  • 15
  • 36