As part of our build process we deploy our web applications using MSDeploy. This worked perfect until a few weeks ago (I think when we updated our build/TFS server to SP1 of TFS 2010).
In our build definition there is a step to invoke a process. This process will call the generated deploy.cmd file and passes in a couple of additional parameters. This worked fine for a long time, but now we get this:
Error: Unrecognized argument '"-skip:objectName=filePath,absolutePath=.*cmsservices.config"'. All arguments must begin with "-".
As described in the help we pass the additional arguments in with quotes:
WebApplication.deploy.cmd /Y /M:sv-ad-iis02 -allowUntrusted "-skip:objectName=filePath,absolutePath=.*cmsservices.config" "-skip:objectName=filePath,absolutePath=.*servicemodel.client.config" "-skip:objectName=dirPath,absolutePath=app_data"
However, this trick does no longer works. Removing the quotes will also remove any characters like = and , which will be replaced by spaces.
I traced it back (by comparing an old deploy.cmd with a new version) to this line:
Line 76:
@rem Any addition flags, pass through to the msdeploy
set _ArgMsDeployAdditionalFlags=%_ArgMsDeployAdditionalFlags% %_ArgCurrentOriginal%
In the previous version this was:
@rem Any addition flags, pass through to the msdeploy
set _ArgMsDeployAdditionalFlags=%_ArgMsDeployAdditionalFlags% %_ArgCurrent%
The _ArgCurrentOriginal uses the %1 instead of %~1 and if I change this code, it all works again. However the deploy.cmd file is auto generated each time (at least it looks like)
Any clue why this has been changed and how to deal with this?
Update; I worked around this problem by using the environment variable to pass in these values. It still does not solve the issue that the new deploy.cmd files are escaping quotes in a different way.
The solution I now placed in my deploy process workflow:
<mtbwa:InvokeProcess Arguments="[String.Format("/Y /M:{0} -allowUntrusted", DeploymentServerName)]" DisplayName="Deploy selected Web Application using MSDeploy" EnvironmentVariables="[New Dictionary(Of String, String) From {{"_MsDeployAdditionalFlags", DeploymentParameters}}]" FileName="[String.Format("{0}\Packages\{1}\{2} {3}\{4}.deploy.cmd", BuildDetail.DropLocation, platform.Configuration, ApplicationName, VersionString, DeploymentPackageName)]" sap:VirtualizedContainerService.HintSize="464,420" Result="[ExitCode]">