cake-build / cake-build/cake

Unable to run script specified by -script argument on TeamCity

Open
#2,376 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.2k
Forks
778
Avg merge
1h 15m
Merged PRs (30d)
19

Description

### What You Are Seeing?
Running on TeamCity in the Powershell runner, Cake fails to execute the script specified by the `-script` argument.

### What is Expected?
Running on TeamCity in the Powershell runner, Cake executes the specified build script

### What version of Cake are you using?
0.30.0

### Are you running on a 32 or 64 bit system?
x64

### What environment are you running on? Windows? Linux? Mac?
Windows Server 2012 R2

### Are you running on a CI Server? If so, which one?
TeamCity 2018.1.4

### How Did You Get This To Happen? (Steps to Reproduce)
Use Powershell runner.
Script file: ./build.ps1
Script arguments:

-script=%teamcity.build.workingDir%\projapi.cake
-SkipToolPackageRestore
-target=test
-configuration=release
-branch=%vcsroot.myproj.branch%
-msBuildLogger="%teamcity.dotnet.msbuild.extensions4.0%"
-verbosity=diagnostic

### Output Log
~~~sh
[13:26:35]E: Step 1/1: Build MyProj API (PowerShell) (2s)
[13:26:36]i: [Step 1/1] PowerShell running in non-virtual agent context
[13:26:36] : [Step 1/1] PowerShell Executable: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
[13:26:36] : [Step 1/1] Working directory: E:\B2\work\71cf44a529edf336
[13:26:36] : [Step 1/1] Command: C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe
[13:26:36] : [Step 1/1] PowerShell arguments: -Version, 4.0, -NoProfile, -NonInteractive, -ExecutionPolicy, ByPass, -File, E:\B2\work\71cf44a529edf336\build.ps1, -Mono, -Experimental, -script=E:\B2\work\71cf44a529edf336\someapi.cake, -SkipToolPackageRestore, -target=test, -configuration=release, -branch=/main, -msBuildLogger="C:\BuildAgent2\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MSBuildLoggers.4.0.dll", -verbosity=diagnostic
[13:26:37] : [Step 1/1] Preparing to run build script...
[13:26:37] : [Step 1/1] Running build script...
[13:26:37] : [Step 1/1] Module directory does not exist.
[13:26:37] : [Step 1/1] NuGet.config not found.
[13:26:37] : [Step 1/1] Analyzing build script...
[13:26:37]W: [Step 1/1] E:/B2/work/71cf44a529edf336/build.cake:0: Could not find script 'E:/B2/work/71cf44a529edf336/build.cake'.
[13:26:38]W: [Step 1/1] Error: Cake.Core.CakeException: Errors occured while analyzing script.
[13:26:38]W: [Step 1/1] at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
[13:26:38]W: [Step 1/1] at Cake.Commands.BuildCommand.Execute(CakeOptions options)
[13:26:38]W: [Step 1/1] at Cake.CakeApplication.Run(CakeOptions options)
[13:26:38]W: [Step 1/1] at Cake.Program.Main()
[13:26:38]W: [Step 1/1] Process exited with code 1
[13:26:37]E: [Step 1/1] Process exited with code 1 (Step: Build MyProj API (PowerShell))
[13:26:38]E: [Step 1/1] Step Build MyProj API (PowerShell) failed
~~~

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the TeamCity PowerShell runner invocation using build.ps1 and the -script path for projapi.cake. Then trace the ScriptRunner and BuildCommand entry points shown in the stack trace to determine why E:/B2/work/71cf44a529edf336/build.cake is selected instead; done means the specified script executes successfully with the listed arguments.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
build-system, ci-cd, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.