2014-11-05 63 views
0

我目前正在调整我的msbuild文件以进行持续集成。更具体地说,我试着调用powershell在msbuild文件中的远程服务器上执行任务,遵循Microsoft official help的指导。除了“& amp;”之外,一切都很棒在msbuild文件中不会被替换为“&”。例如,&在XML中不被替换为&

<Exec Command="powershell.exe -NonInteractive -executionpolicy Unrestricted 
       -command &quot;&amp; invoke-command 
          -Computername &apos;RemoteServer&apos; 
          -scriptblock {...} 
          &quot;"/> 

当的msbuild脚本包含上述执行,该命令被翻译为

powershell.exe -NonInteractive -executionpolicy Unrestricted 
      -command "&amp; invoke-command 
         -Computername 'RemoteServer' 
         -scriptblock {...} 
         " 

正如你可以看到, “& QUOT;”和“&”;“被成功翻译,而“& amp”不是。

任何线索都非常感谢!

回答

0

即使执行msbuild脚本会抱怨命令并显示“& amp”在消息中。但这不是问题的根源。

根是msbuild脚本不喜欢单个powershell命令传播多行。

<Exec Command="powershell.exe -NonInteractive -executionpolicy Unrestricted -command &quot;&amp; invoke-command -Computername &apos;RemoteServer&apos; -scriptblock {...} &quot;"/> 

有一次我像上面那样改变它。它按预期工作。