views:

253

answers:

1

I'm using msdeploy.exe run from TeamCity for deploying ASP.Net projects to staging servers but if suffers severely from always returning a 0 status on exit, even when it raises several errors. This means that a bad deploy does not fail and all looks OK.

So I need to parse the output and have that raise an error, is there an easy way to do this? Alternatively, is there a hard way to do this?

You can see from the TeamCity build log below what is going on (errors, but carries on due to 0 exit status).

[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
+2  A: 

Here is an approach I used to catpure build failures from MSDeploy when I ran a Nant script for deployment remotely. It is not an identical scenerio but should give you a concept to go from. Basically you can run this from a shell you need a scripting language like powershell to capture the output and than post processes the plain text coming back from msdeploy. I rasied this issue with the MSDeploy team and let them know this was a pain to deal with.

http://www.lostechies.com/blogs/hex/archive/2009/12/29/update-on-using-msdeploy-for-remote-deployments.aspx

Eric Hexter