2014-11-05 65 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;"/> 

有一次我像上面那樣改變它。它按預期工作。