CruiseControl.Net与PowerShell不兼容

3

以下是我的 PowerScript 任务

<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>

错误是这样的...
<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>

问题出在scriptsDirectory。驱动器名称“Program Files”中有一个空格。
如果我尝试在它周围加上'或",cruisecontrol会显示无效驱动器。 任何帮助都将是非常棒的。

PowerShell版本为V2

CruiseControl.Net版本为1.5.6755.1

2个回答

4

您还可以尝试使用8个字符的目录名。如果运行dir /x,您将看到这些名称已经被缩短了。它们永远不会有空格,因此这是避免转义字符问题的好方法。在您的情况下,它应该看起来像c:\PROGRA~1\CRUISE~1...


0

好的,如果它不接受引号(你尝试过在XML语法中使用引号吗?),根据你的系统,也许你可以创建一个链接到正确驱动器的路径,这样你就可以使用指向 PowerShell 可执行文件的新路径:

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

然后

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

顺便问一下,如果你使用的是 Powershell V2,那么这是正确的路径吗?


根据OP的说法,问题不在<executable/>路径上,而是在<scriptsDirectory/>路径上。除此之外,这对我来说看起来是个好主意。 - Brian Bassett

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接