我正在使用从 TeamCity 运行的 msdeploy.exe 将 ASP.Net 项目部署到登台服务器,但如果在退出时总是返回 0 状态,即使它引发了几个错误,也会受到严重影响。这意味着错误的部署不会失败,并且看起来一切正常。
所以我需要解析输出并引发错误,有没有简单的方法可以做到这一点?或者,有没有很难做到这一点的方法?
您可以从下面的 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