none
MSDeploy CMD file built by MSBuild does not return MSDeploy RC RRS feed

  • Question

  • We're running MSBuild with DeployOnBuild=True and CreatePackageOnPublish=True to create a deployable package we can store for later deployment. These options also create a .CMD file that one can theoretically use to run MSDeploy. The problem is that if MSDeploy fails the .CMD file still returns an RC of 0. I'm running this in a scripted workflow solution and if the .CMD file returns 0 then it assumes everything worked (logical) when in fact the MSDeploy may have failed. The only way to know is to check the log.

    Has anyone worked with this methodology? Is there any way to get the .CMD file to fail if the MSDeploy command fails without making major manual mods to the .CMD file?

    Friday, May 31, 2013 5:15 PM

Answers

  • Ugh... I just found this in the IIS.Net forums:

    http://forums.iis.net/t/1148039.aspx

    Apparently MSDeploy always returns a 0 return code regardless of the status of the deployment. This is unacceptable if MS expects MSDeploy to be used as the method for deploying web applications as is evidenced by the increasing reliance on it in newer versions of IIS. How do we get the requirement for MSDeploy to return non-zero return codes for failed deployments into Microsoft's work queue?

    Tuesday, June 4, 2013 11:58 AM

All replies

  • Hi,

    From your post, I can't know what problem you have. Please post the detail msbuild log.

    I guess that you have a custom msbuild project, if yes, please post its content here.

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, June 3, 2013 8:44 AM
    Moderator
  • It isn't a complex MSBuild. The log from the step that executes MSBuild simply runs:

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe TestVS10XML.sln /nologo /v:n /p:Configuration=Debug /p:TargetFramework=v4.0

    /p:DeployOnBuild=True /p:CreatePackageOnPublish=True

    which results in a set of files:

    TestVS10XML.SetParameters.xml

    TestVS10XML.SourceManifest.xml

    TestVS10XML.Deploy.cmd

    TestVS10XML.zip <-- contains the deployable code.

    Running TestVS10XML.Deploy.cmd from within a BAT file is fine if the embedded generated MSDeploy command succeeds. There is no test in TestVS10XML.Deploy.cmd for successful completion of MSDeploy so the TestVS10XML.Deploy.cmd file returns a 0 even if the MSDeploy fails. Since the TestVS10XML.Deploy.cmd file is being run by a larger script the remainder of the script continues to run despite checking for a non-zero RC from Deploy.cmd. There is no way for me to attach the related files (i.e TestVS10XML.Deploy.cmd) and this post would be a mile long if I embedded the source of the cmd file in the body of the post.

    My original question is about the TestVS10XML.Deploy.cmd file generated by MSBuild with the above parameters and whether or not there is a way to get the TestVS10XML.Deploy.cmd file generated such that it returns a non-zero RC if the MSDeploy command fails.

    The solution being built is a "Hello World" web app built simply for the purpose of testing the MSBuild/MSDeploy workflow. THis problem can be easily recreated by creating a new web app solution, building it with the MSBuild command above, and running the generated CMD file specifying a server that does not exist. This will cause MSDeploy to fail but the CMD file will not fail.


    • Edited by RSchaefer Monday, June 3, 2013 10:45 AM
    Monday, June 3, 2013 10:41 AM
  • Output from running the Deploy.cmd file:

    command output:
     e:\build\agent1\RWS_Test_Web_Build\Microsoft_Deploy_Web_App\trunk>TestVS10XML.deploy.cmd /Y /M:ad1hfdadm801
     =========================================================
     SetParameters from:
     "e:\build\agent1\RWS_Test_Web_Build\Microsoft_Deploy_Web_App\trunk\TestVS10XML.SetParameters.xml"
     You can change IIS Application Name, Physical path, connectionString
     or other deploy parameters in the above file.
     -------------------------------------------------------
      Start executing msdeploy.exe
     -------------------------------------------------------
      "C:\Program Files\IIS\Microsoft Web Deploy V3\\msdeploy.exe" -source:package='e:\build\agent1\RWS_Test_Web_Build\Microsoft_Deploy_Web_App\trunk\TestVS10XML.zip' -dest:auto,computerName='ad1hfdadm801',includeAcls='False' -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"e:\build\agent1\RWS_Test_Web_Build\Microsoft_Deploy_Web_App\trunk\TestVS10XML.SetParameters.xml"
     Info: Using ID 'bccc6fbe-e238-4a3f-b120-479be1a38435' for connections to the remote server.
     Error Code: ERROR_COULD_NOT_CONNECT_TO_REMOTESVC
     More Information: Could not connect to the remote computer ("smprovider.thehartford.com") using the specified process ("Web Deployment Agent Service") because the server did not respond. Make sure that the process ("Web Deployment Agent Service") is started on the remote computer. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC.
     Error: The remote server returned an error: (500) Internal Server Error.
     Error count: 1.
     ===============================

     command exit code: 0

    It is clear the MSDeploy command cannot execute and returns an error to Deploy.cmd but Deploy.cmd is not testing the results of the MSDeploy command and itself returns an RC of 0.

    Monday, June 3, 2013 11:11 AM
  • Some results from my own stand-alone execution of MSDeploy. If I run specifying a valid server that supports Web Deploy I get:

     C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe -verb:sync -source:package=TestVS10XML.zip -dest:auto=computerName=ad1hfdadm902,includeAcls=False -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension
     command: 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' -verb:sync -source:package=TestVS10XML.zip -dest:auto=computerName=ad1hfdadm902,includeAcls=False -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension
     Info: Adding sitemanifest (sitemanifest).
     Info: Creating application (Default Web Site/TestVS10XML_deploy)
     Info: Adding virtual path (Default Web Site/TestVS10XML_deploy)
     Info: Adding directory (Default Web Site/TestVS10XML_deploy).
     Info: Adding directory (Default Web Site/TestVS10XML_deploy\bin).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\bin\AjaxControlToolkit.dll).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\bin\amqmdnet.dll).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\bin\BusinessLayer.dll).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\bin\BusinessLayer.pdb).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\bin\DataAccessLayer.dll).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\bin\DataAccessLayer.pdb).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\bin\TestVS10XML.dll).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\bin\TestVS10XML.pdb).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\Default.aspx).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\Global.asax).
     Info: Adding directory (Default Web Site/TestVS10XML_deploy\Scripts).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\Scripts\jquery-1.9.1-vsdoc.js).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\Scripts\jquery-1.9.1.js).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\Site.Master).
     Info: Adding directory (Default Web Site/TestVS10XML_deploy\Styles).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\Styles\Site.css).
     Info: Adding file (Default Web Site/TestVS10XML_deploy\Web.config).
     Info: Adding ACL's for path (Default Web Site/TestVS10XML_deploy)
     Info: Adding ACL's for path (Default Web Site/TestVS10XML_deploy)
     Total changes: 24 (23 added, 0 deleted, 1 updated, 0 parameters changed, 4911377 bytes copied)
     ===============================
     command exit code: 0

    If I run pointing to a web server with Web Deploy disabled I get:

     C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe -verb:sync -source:package=TestVS10XML.zip -dest:auto=computerName=ad1hfdadm801,includeAcls=False -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension
     command: 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' -verb:sync -source:package=TestVS10XML.zip -dest:auto=computerName=ad1hfdadm801,includeAcls=False -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension
     Info: Adding ACL's for path (Default Web Site/TestVS10XML_deploy)
     Info: Adding ACL's for path (Default Web Site/TestVS10XML_deploy)
     Total changes: 2 (0 added, 0 deleted, 2 updated, 0 parameters changed, 0 bytes copied)
     ===============================
     command exit code: 0

    Why doesn't MSDeploy throw an error if it cannot connect to the web server or the Web Deploy service isn't running? The only difference between the two MSDeploy commands is the target server....

    Monday, June 3, 2013 2:57 PM
  • As far as I can tell from reading these posts they don't address my issue. I understand how the Package target works. I know what the XML, CMD and ZIP files are used for. My problem is that when the MSDeploy command generated by the CMD file fails the error isn't propagated to the CMD file and, worse yet, to the calling script in our deployment tool. This results in the appearance that the deployment succeeded when in fact it may not have. The only way to check is to read the logs.

    I may end up having to forsake the CMD file and script the MSDeploy command myself so I can inspect the errorlevel internal variable and see if it reflects a non-zero RC when MSDeploy fails. If so then I can script a failure of the calling script (exit /B %errorlevel%) and fail the deployment job.

    Tuesday, June 4, 2013 10:58 AM
  • Ugh... I just found this in the IIS.Net forums:

    http://forums.iis.net/t/1148039.aspx

    Apparently MSDeploy always returns a 0 return code regardless of the status of the deployment. This is unacceptable if MS expects MSDeploy to be used as the method for deploying web applications as is evidenced by the increasing reliance on it in newer versions of IIS. How do we get the requirement for MSDeploy to return non-zero return codes for failed deployments into Microsoft's work queue?

    Tuesday, June 4, 2013 11:58 AM
  • Hi,

    It seems that you have find the cause. From your post, I feel it is more related to MSDeploy which we don't support here. You had better ask this question from:

    http://forums.iis.net/1144.aspx/1?Web+Deployment+Tool+MS+Deploy+

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, June 5, 2013 7:53 AM
    Moderator