Kategorien
Allgemein

CruiseControl.NET, Powershell and paths with spaces

Yesterday I included the execution of a Windows Powershell task into our CruiseControl.Net Buildserver in order to include the execution of some (more) tests into the build. I stumbled upon a posting of Vasily from QA Questions on how to do that: CruiseControl.NET: PowerShell tasks, otherwise I would have tried using the CruiseControl´s Exec-task to do it.

Before changing CruiseControl´s configuration I tried to make it work on the command line, just to go sure the Powershell script is doing what it is expected to do and found out that handling blanks in paths is a -bit- very weird when using PowerShell, but I found a solution described by Dave Donaldson at his blog: Running a PowerShell Script with a Space in the Path, which worked quite well for me.

But when it comes to CruiseControl.NET´s config-file, I still did not manage to execute the powershell script, reason is that there are two entries, one for the scriptpath and one for the script itself; so I´m not able to set the quotes correctly:

<tasks>
  <powershell>
    <script>myScript.ps1</script>
    <executable>C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe</executable>
    <scriptsDirectory>C:\my Directory\anotherDirectory</scriptsDirectory>
    <successExitCodes>0</successExitCodes>
    <buildTimeoutSeconds>60</buildTimeoutSeconds>
  </powershell>
</tasks>

One may argue that I just should place the Powershell script somewhere else, but I don´t like to use dirty workaround if there _must_ be a proper solution. And what if I´m not able to put it somewhere else?
What I´m using for now is to use the old 8-character directory name that was still common back in times of Windows 95, so in this case „C:\MYDIRE~1“. (To find this out, just execute „dir /x“ on the commandline). But I´m not very happy with this solution.

Any ideas/ proposals/ hints how to solve this properly? Thanks in advance!