views:

37

answers:

2

Here is my PowerScript Task

<powershell>
    <script>RunScout3G.ps1</script>
    <executable>C:\WINDOWS\system32\WindowsPowerShell\v1.0\PowerShell.exe</executable>
    <scriptsDirectory>C:\Program Files\CruiseControl.NET\Our_PowerShell</scriptsDirectory>
    <buildArgs></buildArgs>
    <successExitCodes>0</successExitCodes>
    <buildTimeoutSeconds>900</buildTimeoutSeconds>
    <description>Example of how to run a PowerShell script.</description>
  </powershell>

The Error is this...

<buildresults>
<message level="Error">The term 'C:\Program' is not recognized as the name of a cmdlet, function, scri </message>
<message level="Error">pt file, or operable program. Check the spelling of the name, or if a path was </message>
<message level="Error">included, verify that the path is correct and try again.</message>
<message level="Error">At line:1 char:11 </message>
<message level="Error">+ C:\Program <<<<  Files\CruiseControl.NET\JCDC_PowerShell\RunScout3G.ps1 </message>
<message level="Error">    + CategoryInfo          : ObjectNotFound: (C:\Program:String) [], CommandN </message>
<message level="Error">   otFoundException </message>
<message level="Error">    + FullyQualifiedErrorId : CommandNotFoundException </message>
<message level="Error"> </message>

The problem is with scriptsDirectory. There is a space in the drive name "Program Files".
If I try and put ' around it, or " around it cruisecontrol says invalid drive. Any help would be awesome.

Version of PowerShell is V2

Version of CruiseControl.Net is 1.5.6755.1

A: 

OK, if it doesn't accept quotes (have you tried " in the XML syntax?), depending on your system, maybe you can make a link to the correct drive, such that you can use the new path to the powershell executable:

mklink /D c:\powershell "C:\WINDOWS\system32\WindowsPowerShell\v1.0"

and then

<script>RunScout3G.ps1</script>
<executable>C:\powershell\PowerShell.exe</executable>

btw, if you use Powershell V2, is that the correct path?

flq
According to the OP, the issue isn't with the path in <executable/>, but with the path in <scriptsDirectory/>. Other than that, this looks like a good idea to me.
Brian Bassett
+2  A: 

You could also try using the 8 character directory names. If you run dir /x you will see the shortened names. They will never have any spaces in them, so it's a nice way to avoid the escaped character issues. In your case it should look like c:\PROGRA~1\CRUISE~1...

jwmiller5
Changing <ScriptsDirectory> to 8.3 path worked well.
Razcer