指定文件夹,不要在Web部署同步 [英] Specifying folders not to sync in Web Deploy

查看:1408
本文介绍了指定文件夹,不要在Web部署同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的脚本到我的ASP.NET MVC应用程序部署到我们的Web服务器:

I use the following script to deploy my ASP.NET MVC app to our web server:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe MySolution.sln^
/p:Configuration=TeamCity-Test^
/p:OutputPath=bin^
/p:DeployOnBuild=True^
/p:DeployTarget=MSDeployPublish^
/p:MsDeployServiceUrl=https://mywebserver.com:8172/msdeploy.axd^
/p:username=MyDomain\MyUser^
/p:password=MyPassword^
/p:AllowUntrustedCertificate=True^
/p:DeployIisAppPath=mywebsitename.com^
/p:MSDeployPublishMethod=WMSVC

现在我需要指定不同步/上传文件夹中。我可以指定这个脚本?谢谢!

Now I need to specify to not sync the /uploads folder. Can I specify that in this script? Thanks!

澄清:
我有我的项目中上传文件夹。我想为Web部署创建文件夹。我不希望它从我的Web服务器删除该文件夹/子文件夹/文件,因为它包含用户上传的内容。

Clarification: I have the Uploads folder in my project. I'd like for Web Deploy to create the folder. I do not want it to delete the folder/subfolders/files from my web server because it contains user-uploaded content.

澄清#2:
我刚刚发现的 SkipExtraFilesOnServer = TRUE 选项。不过,我不希望这是全球性的。我想将它设置为一个单一的文件夹中。

Clarification #2: I just found the SkipExtraFilesOnServer=True option. However, I don't want this to be global. I'd like to set it to a single folder.

推荐答案

更新:
显然,你真正想要的是prevent网络从目标服务器上删除现有目录进行部署的,但仍然有文件夹中创建的情况下,它不存在。你可以做到这一点如下:

UPDATE: Apparently, what you really want is prevent web deploy from removing existing directory on the destination server, but still have the folder created in case it's not there. You can accomplish this as follows:


  • 创建 YourWebProjectName.wpp.targets 文件在你旁边包含以下内容的项目文件:

  • create YourWebProjectName.wpp.targets file next to you the project file with the following content:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
      <MsDeploySkipRules Include="SkipELMAHFolderFiles">
      <SkipAction></SkipAction>
      <ObjectName>filePath</ObjectName>
      <AbsolutePath>$(_DestinationContentPath)\\NameOfYourFolder\\.*</AbsolutePath>
      <Apply>Destination</Apply>
      <XPath></XPath>
    </MsDeploySkipRules>

    <MsDeploySkipRules Include="SkipELMAHFolderChildFolders">
      <SkipAction></SkipAction>
      <ObjectName>dirPath</ObjectName>
      <AbsolutePath>$(_DestinationContentPath)\\NameOfYourFolder\\.*\\*</AbsolutePath>
      <Apply>Destination</Apply>
      <XPath></XPath>
    </MsDeploySkipRules>
  </ItemGroup>
</Project>


修改 NameOfYou​​rFolder YourWebProjectName 相应。这是假设,你有它的根,我相信,你可以,如果不是这样使用相对路径。

Change NameOfYourFolder and YourWebProjectName accordingly. This assumes, you have it in the root, I believe, you can use relative path if it's not the case.


  • 第一个 MsDeploySkipRules 项告诉webdeploy不要删除 Name_OfYou​​rFolder
  • 的任何文件
  • 第二个 MsDeploySkipRules 告诉webdeploy不要删除任何子文件夹的 Name_OfYou​​rFolder

  • The first MsDeploySkipRules entry tells webdeploy not to remove any files in Name_OfYourFolder.
  • The second MsDeploySkipRules tells webdeploy not to remove any child folders in Name_OfYourFolder.

另外,有如果不是在目标服务器上present的文件夹中创建,你必须做到以下几点:

Also, to have the folder created if it's not present on the destination server, you have to do the following:


  • 包括文件夹到项目

  • 添加一个虚拟的 DeployemntPlaceholder.txt 文件到它并将其包含到项目以及

  • include the folder into the project
  • add a dummy DeployemntPlaceholder.txt file into it and include it into the project as well

DeployemntPlaceholder.txt 需要告诉的MSBuild文件夹添加到包:空文件夹都将被忽略

DeployemntPlaceholder.txt is required to tell MSBUild to add the folder into the package: empty folders are ignored.

我测试过这种方法,当你运行你显示的方式公布它工作正常。我用这个答案得到的MSBuild项目syntaxt权利。我相信,这是一个MSBuild的方式来定制标志,路过的MSBuild部署管道webdeploy。

I've tested this approach and it works fine when you run publish in the manner you've shown. I've used this answer to get the msbuild items syntaxt right. I believe, this is a MSBuild way to customize flags, passed to webdeploy by MSBuild Deployment Pipeline.

如果你直接奔MSDeploy,您可以通过以下方式使用跳跃参数:

If you ran MSDeploy directly, you could use skip arguments in the following manner:

-skip:objectname='filePath',absolutepath='logs\\.*\\someNameToExclude\.txt'

更新2

Conserning原题指定的文件夹不要在Web部署同步,做到这一点最简单的方法如下:

Conserning the original question "Specifying folders not to sync in Web Deploy", the easiest way to do this is as follows:

您可以创建一个发布配置文件,并添加以下行:

You can create a publish profile and add the following lines:

<PropertyGroup>
  <ExcludeFilesFromDeployment>
    File1.aspx;File2.aspx
  </ExcludeFilesFromDeployment>
  <ExcludeFoldersFromDeployment>
    Folder1;Folder2
  </ExcludeFoldersFromDeployment>
</PropertyGroup> 

我测试过这种方法使用发布配置文件中排除文件。一个简单的指南是<一个href=\"http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/deploying-to-production\">here (滚动 编辑.pubxml文件以排除的robots.txt 部分)。

I've tested this approach for excluding files using publish profiles. An easy guide is here (scroll to Edit the .pubxml file to exclude robots.txt section).

您也可以做到这一点的.wpp.targets文件或您的csproj编辑。查看更多信息的<一个href=\"http://msdn.microsoft.com/en-us/library/ee942158.aspx#can_i_exclude_specific_files_or_folders_from_deployment\">Web部署常见问题Visual Studio和ASP.NET

You can also do this in .wpp.targets file or edit you csproj. See more information at Web Deployment FAQ for Visual Studio and ASP.NET

这篇关于指定文件夹,不要在Web部署同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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