MSDeploy批处理文件不再处理引号 [英] MSDeploy batch file does not handle quotes anymore

查看:105
本文介绍了MSDeploy批处理文件不再处理引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为构建过程的一部分,我们使用MSDeploy部署Web应用程序.直到几周前,它才完美运行(我认为当我们将build/TFS服务器更新为TFS 2010的SP1时.)

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).

在我们的构建定义中,有一个步骤来调用流程.此过程将调用生成的deploy.cmd文件,并传入几个其他参数.很长一段时间都可以正常工作,但是现在我们得到了:

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:

错误:无法识别的参数'"-skip:objectName = filePath,absolutePath =.* cmsservices.config"'.所有参数都必须以-"开头.

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 -allow不受信任的"-skip:objectName = filePath,absolutePath =.* cmsservices.config""-skip:objectName = filePath,absolutePath =.* servicemodel. client.config" -skip:objectName = dirPath,absolutePath = app_data"

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.

我通过将旧的deploy.cmd与新版本进行比较来追溯到此行:

I traced it back (by comparing an old deploy.cmd with a new version) to this 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%

_ArgCurrentOriginal使用%1 而不是%〜1 ,如果我更改此代码,它们将再次起作用.但是,每次都会自动生成deploy.cmd文件(至少看起来像这样)

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?

更新;我通过使用环境变量来传递这些值来解决此问题.仍然不能解决新的deploy.cmd文件以不同的方式转义引号的问题.

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(&quot;/Y /M:{0} -allowUntrusted&quot;, DeploymentServerName)]" DisplayName="Deploy selected Web Application using MSDeploy" EnvironmentVariables="[New Dictionary(Of String, String) From {{&quot;_MsDeployAdditionalFlags&quot;, DeploymentParameters}}]" FileName="[String.Format(&quot;{0}\Packages\{1}\{2} {3}\{4}.deploy.cmd&quot;, BuildDetail.DropLocation, platform.Configuration, ApplicationName, VersionString, DeploymentPackageName)]" sap:VirtualizedContainerService.HintSize="464,420" Result="[ExitCode]">

推荐答案

这是SP1版本中引入的错误.您可以通过编辑%ProgramFiles(x86)%\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(注意64位路径)来解决此问题.更改第3238-3258行以匹配旧的deploy.cmd文件中的相应内容;差异仅应像3行,删除_ArgCurrentOriginal并使用_ArgCurrent.

This is a bug introduced in the SP1 release. You can work around it by editing %ProgramFiles(x86)%\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets (note 64-bit path). Change lines 3238-3258 to match the respective contents in the old deploy.cmd file; the diff should only be like 3 lines, removing _ArgCurrentOriginal and using _ArgCurrent.

最近在此问题上还发布了一个知识库文章: http://support.microsoft.com/kb/2537134 .其中包括一个更新的.targets文件,因此您不必自己进行编辑.

There's also a KB recently published on the issue: http://support.microsoft.com/kb/2537134. This includes an updated .targets file so you don't have to make the edit yourself.

这篇关于MSDeploy批处理文件不再处理引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆