我使用msdeploy.exe從TeamCity的運行部署ASP.Net項目,以分期服務器,但如果從總返回退出狀態0,即使它提出了幾個錯誤,患有嚴重。這意味着一個不好的部署不會失敗,並且一切看起來都不錯。如何解析msdeploy的輸出,並在出現錯誤時失敗TeamCity構建?
所以我需要解析輸出,並有引發錯誤,有一個簡單的方法來做到這一點?或者,有沒有很難做到這一點?
您可以從TeamCity的構建日誌下面是怎麼回事看到(錯誤,但進行,由於0退出狀態)。
[17:32:31]: Skip copying Global.asax to obj\Debug\Package\PackageTmp\Global.asax, File obj\Debug\Package\PackageTmp\Global.asax is up to date
[17:32:31]: C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(1845,5): error : Copying file Web.Debug.config to obj\Debug\Package\PackageTmp\Web.Debug.config failed. Could not find file 'Web.Debug.config'. [C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj]
[17:32:31]: Done Building Project "C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj" (Package target(s)) -- FAILED.
[17:32:31]: Build FAILED.
[17:32:31]: "C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj" (Package target) (1) ->
[17:32:31]: (ValidateGlobalPackageSetting target) ->
[17:32:31]: C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(817,5): error : '..\Package\WebApp.zip' exists as a file. You can't package as an archive directory to be the same path as an existing file. Please delete the file before packaging. Alternative,you can call msbuild with /t:CleanWebsitesPackage target to remove it. [C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj]
[17:32:31]: "C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj" (Package target) (1) ->
[17:32:31]: (CopyAllFilesToSingleFolderForPackage target) ->
[17:32:31]: C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(1845,5): error : Copying file Web.Debug.config to obj\Debug\Package\PackageTmp\Web.Debug.config failed. Could not find file 'Web.Debug.config'. [C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj]
[17:32:31]: 0 Warning(s)
[17:32:31]: 2 Error(s)
[17:32:31]: Time Elapsed 00:00:00.87
[17:32:31]: C:\BuildAgent\work\f3548ee02a6397b9>"C:\Program Files\IIS\Microsoft Web Deploy"\msdeploy.exe -verb:sync -source:Package=Package\WebApp.zip -dest:auto -setParam:"IIS Web Application Name"=MyWebName
[17:32:32]: Info: Updating setAcl (MyWebName).
[17:32:32]: Info: Updating setAcl (MyWebName).
[17:32:32]: Info: Updating setAcl (MyWebName/App_Data).
[17:32:32]: Total changes: 3 (0 added, 0 deleted, 3 updated, 0 parameters changed, 0 bytes copied)
[17:32:32]: Process exited with code 0
[17:32:32]: Build finished
這是一個很好的解決方案,我完全忽略了一個。它運作良好。僅供參考,我使用的正則表達式文本選項的值爲「錯誤計數:[1-999]」,這似乎適用於基於MSBuild的任務。 – keithl8041 2013-05-14 16:12:49
@ keith8041:這將始終有效,但要注意'[1-999]'意味着:'一個字符可以是1到9,或9或9',它只匹配'錯誤計數:'。我認爲你的意思是:'錯誤計數:[1-9] [0-9] *'。注意:我只是在這裏挑剔。 – 2014-07-04 11:40:27