CruiseControl.Net 与 PowerShell 配合不佳

发布于 2024-09-13 01:11:42 字数 1733 浏览 2 评论 0原文

这是我的 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”中有一个空格。
如果我尝试将 ' 放在它周围,或者 " 放在它周围,巡航控制会说无效驱动。 任何帮助都会很棒。

PowerShell 版本为 V2

CruiseControl.Net 版本为 1.5.6755.1

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

莫言歌 2024-09-20 01:11:42

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

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

舟遥客 2024-09-20 01:11:42

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

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

然后

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

顺便说一句,如果您使用 Powershell V2,这是正确的路径吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文