MSDeploy使用备忘

      使用MSDeploy命令行部署站点的时候,碰到一个问题:默认情况下,部署的过程中,会把目标目录下面的内容都清空,但是有的时候部署的站点已经有用户在使用,比如说内容维护,用户上传了一些文件到站点目录下面,,这样的话,部署的时候就造成会把用户的文件给清除了,也就是要想办法做到能控制部署的时候是否要清空目标目录,在在线MSDN帮助中找到答案:

 

http://technet.microsoft.com/en-us/library/dd569019%28WS.10%29.aspx其中的如下例子:

Unpackage the contents of the Package.zip file and put them in the C:\temp folder. Do not delete other files that already exist in the destination folder.

msdeploy.exe -verb:sync -source:package=C:\package.zip -dest:contentpath=C:\temp -enableRule:DoNotDeleteRule

只要在部署脚本中写入-enableRule:DoNotDeleteRule参数就可以了。如下所示:

 

 

<Target Name="MSDeploy">
    <MSBuild Targets="Package" Projects="..\src\Avatar.Application.WuJingPortal.Web\Avatar.Application.WuJingPortal.Web.csproj" ContinueOnError="false" Properties="PackageLocation=..\..\output\Package.zip"/>
    <Exec Command="..\output\Package.deploy.cmd /Y /m:$(DeployServerIP) /u:$(DeployUser) /p:&quot;$(DeployPossword)&quot; -enableRule:DoNotDeleteRule" ContinueOnError="false" IgnoreExitCode="true" />
  </Target>

 问题解决。

   部署过程中,要确保目标主机的80端口是可以访问的,要不然会出现部署失败的情况。

 

posted on 2012-08-30 14:00  文魁  阅读(767)  评论(0编辑  收藏  举报

导航