Question

I am running msdeploy (in powershell, as part of a script) with a runcommand provider as a postsync step, which runs a batch file on the remote machine. The batch file just executes exit /b 1 which causes it to return a failure code.

I am using msdeploy v3, and have specified successReturnCodes=0 as a provider parameter.

I can see the batch file executing, I can see that msdeploy recognises that it's an error, and logs the fact:

Performing '-postSync'...
Info: Using ID '892ee111-27c1-458d-888d-ead28fcab742' for connections to the remote server.
Info: Using ID '49ee88fc-0e1d-4eff-8a75-bccf0e7d680a' for connections to the remote server.
Info: Updating runCommand (d:\testdeploy\test\test.bat).
Info:

Info: C:\Windows\system32>exit /b 1

Error: (13/06/2013 6:06:03 PM) An error occurred when the request was processed on the remote computer.
Error: The process 'C:\Windows\system32\cmd.exe' (command line '') exited with code '0x1'.
Error count: 1.
Error during '-postSync'.

Total changes: 1 (0 added, 0 deleted, 1 updated, 0 parameters changed, 6 bytes copied)
D:\TestDeploy> $LASTEXITCODE
0

However, msdeploy returns successfully, $LASTEXITCODE is 0.

Is there any way to tell that msdeploy has actually caught an error? (without resorting to capturing the output of msdeploy and checking for the presence of 'Error count:'? :)

Était-ce utile?

La solution 2

It turns out it was due to a mix up in versions between msdeploy v2 and v3. The only combination that will return the exit code correctly is v3 client and v3 service. I was using the v3 client but mistakenly connecting with it to a v2 service.

Richard Szalay is correct, the successReturnCodes just changes the log of the return code from warning to info.

Autres conseils

It seems that if you remove successReturnsCodes, it will only report as a warnig but msdeploy will return the correct return code.

I'd recommend you file this as a bug on the MSDeploy forums.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top