cake-build / cake-vso

Cake integration for Azure DevOps.
https://marketplace.visualstudio.com/items/cake-build.cake
18 stars 18 forks source link

build.cake fails with tool installation using vso extension, works using bootstrapper #19

Closed dennisroche closed 6 years ago

dennisroche commented 8 years ago

What You Are Seeing?

An error when installing a tool when running build.cake via VSTS extension. Error: Cake.Core.CakeException: Failed to install tool 'GitVersion.CommandLine'.

What is Expected?

build.cake to execute the same if executed using the build.ps1 bootstrapper. Using build.ps1 on the build agent executes as expected.

What version of Cake are you using?

<packages>
    <package id="Cake" version="0.14.0" />
</packages>

Using 0.1.7 that was updated ‎25‎/‎06‎/‎2016‎ ‎3‎:‎43‎:‎49‎ ‎AM

Are you running on a 32 or 64 bit system?

Using a hosted agent on VSTS which is Windows Server 2012 R2, 64-bit environment, with Windows PowerShell

What environment are you running on? Hosted? Custom?

Hosted.

How Did You Get This To Happen? (Steps to Reproduce)

https://gist.github.com/dennisroche/084eff333760f2bf473f7dff6746997d

The above gist has the build.cake and the contents of the tools\**. I've using a nuget.config file to workaround the issue https://github.com/cake-build/cake-vso/issues/5.

Remember, this works it using the build.ps1 bootstrapper.

Output Log

******************************************************************************
Starting task: Build using Cake
******************************************************************************

Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.102.0\tasks\Cake\0.1.7\Cake.ps1
Restoring packages...
Installing 'Cake 0.14.0'.
Successfully installed 'Cake 0.14.0'.
C:\a\1\s\tools\Cake\Cake.exe "C:\a\1\s\build.cake" -target="Default" -verbosity="Diagnostic" --paths_tools="C:\a\1\s\tools" -configuration="Release" -output="C:\a\1\a"
Module directory does not exist.
Analyzing build script...
Analyzing C:/a/1/s/build.cake...
Processing build script...
Installing tools...
Installing NuGet package GitVersion.CommandLine...
Executing: "C:/a/1/s/tools/nuget.exe" install "GitVersion.CommandLine" -OutputDirectory "C:/a/1/s/tools" -ExcludeVersion -NonInteractive -NoCache

Unable to find package 'GitVersion.CommandLine'.
NuGet exited with 1
Output:

Error: Cake.Core.CakeException: Failed to install tool 'GitVersion.CommandLine'.
    at Cake.Core.Scripting.ScriptProcessor.InstallTools(ScriptAnalyzerResult analyzerResult, DirectoryPath installPath)
    at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
    at Cake.Commands.BuildCommand.Execute(CakeOptions options)
    at Cake.CakeApplication.Run(CakeOptions options)
    at Cake.Program.Main()
    System.Exception: Unexpected exit code 1 returned from tool Cake.exe
    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeToolCmdlet.ProcessRecord()
    at System.Management.Automation.CommandProcessor.ProcessRecord()

******************************************************************************
Finishing task: Cake
******************************************************************************
gep13 commented 8 years ago

@dennisroche hmm, I am not able to reproduce this issue...

Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.102.0\tasks\Cake\0.1.7\Cake.ps1
Creating tools directory...
Installing Cake...
Installing 'Cake 0.14.0'.
Successfully installed 'Cake 0.14.0'.
C:\a\1\s\Build\tools\Cake\Cake.exe "C:\a\1\s\Build\build.cake" -target="Default" -verbosity="Diagnostic" --paths_tools="C:\a\1\s\Build\tools" --BuildScriptsDirectory="C:\Development\VSTS\Build" --OutputDirectory="C:\a\1\a" --MajVer=11 --MinVer=12 --Patch=13
Module directory does not exist.
Analyzing build script...
Analyzing C:/a/1/s/Build/build.cake...
Processing build script...
Installing tools...
Installing NuGet package NUnit.ConsoleRunner...
Executing: "C:/a/1/s/Build/tools/nuget.exe" install "NUnit.ConsoleRunner" -OutputDirectory "C:/a/1/s/Build/tools" -Version "3.2.1" -ExcludeVersion -NonInteractive -NoCache
Installing NuGet package GitVersion.CommandLine...
Executing: "C:/a/1/s/Build/tools/nuget.exe" install "GitVersion.CommandLine" -OutputDirectory "C:/a/1/s/Build/tools" -ExcludeVersion -NonInteractive -NoCache
Creating script session...
Downloading and installing Roslyn...

I am NOT using a nuget.config file, as the issue that you reference was actually closed in version 0.1.7.

Have you tried this without using a nuget.config file?

gep13 commented 8 years ago

This is the project that I used for testing...

https://github.com/gep13/CakeVstsTest/blob/master/Build/build.cake

dennisroche commented 8 years ago

@gep13 thanks for taking the time to look at this

Removing the nuget.config from the tools/ folder, results in

******************************************************************************
Starting task: Cake
******************************************************************************
Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.102.0\tasks\Cake\0.1.7\Cake.ps1
Restoring packages...
System.Management.Automation.RemoteException: Unable to find version '0.14.0' of package 'Cake'.
Installing Cake...
System.Management.Automation.RemoteException: Unable to find package 'Cake'.
System.Management.Automation.RuntimeException: Could not find Cake.exe at C:\a\1\s\tools\Cake\Cake.exe ---> System.Management.Automation.RuntimeException: Could not find Cake.exe at C:\a\1\s\tools\Cake\Cake.exe
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at Microsoft.TeamFoundation.DistributedTask.Handlers.PowerShellHandler.Execute(ITaskContext context, CancellationToken cancellationToken, Int32 timeoutInMinutes)
at Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.RunTask(ITaskContext context, TaskWrapper task, CancellationTokenSource tokenSource)
******************************************************************************
Finishing task: Cake
*****************************************************************************

I do have another nuget.config in the root of the repository, next to the build.cake.

<?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <!-- http://docs.nuget.org/consume/nuget-config-file -->
   <packageSources>
     <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
     <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
     <add key="libs" value="https://dennisroche.pkgs.visualstudio.com/_packaging/libs/nuget/v3/index.json" />
   </packageSources>
   <bindingRedirects>
    <add key="skip" value="True" />
  </bindingRedirects>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
 </configuration>

If I remove this nuget.config, it then works on VSTS.

As I'm using a private nuget feed, I do need to have this root nuget.config.

gep13 commented 8 years ago

@devlead can you add anything to this one?

@dennisroche when you say you are using a private nuget feed, can you confirm for which part of the build process that is for?

dennisroche commented 8 years ago

the private feed is for our own nupkg's that developed internally - these are pulled in during the dotnet restore. it shouldn't be impacting the build.cake.

gep13 commented 8 years ago

@dennisroche said... these are pulled in during the dotnet restore. it shouldn't be impacting the build.cake.

Agreed, I am not entirely clear on what is going on here.

For now, any reason to not set the sources on the DotNetCoreRestoreSettings class, as per this example:

http://cakebuild.net/api/cake.common.tools.dotnetcore/df2c8647/7df943ec

dennisroche commented 8 years ago

That would work on VSTS, however would break the tooling in VS2015, i.e. wouldn't be able to add update packages from our feed. I could ask the team to manually add the feed to VS2015.

I have a decent workaround using the build.ps1, skipping the VSTS Cake extension.

gep13 commented 8 years ago

@dennisroche said... I have a decent workaround using the build.ps1, skipping the VSTS Cake extension.

What workaround?

dennisroche commented 8 years ago

Running the bootstrap build.ps1 provided by Cake in PowerShell VSTS step.