【问题标题】:Visual Studio 2013 Publish MVC web app - preventing folder deletion from serverVisual Studio 2013 发布 MVC Web 应用程序 - 防止从服务器删除文件夹
【发布时间】:2014-09-24 13:58:26
【问题描述】:

将 MVC 5 Web 应用程序发布到服务器时,我不希望 /images/thumbs 文件夹及其内容被删除。我尝试了很多组合,但文件夹内容总是被清除。我错过了什么?提前致谢!

这是我使用的 ms deploy 命令:

msbuild E:\path_to_project_file\myproject.csproj /p:SkipExtraFilesOnServer=True /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=test.mysite.com.pubxml /p:VisualStudioVersion=12.0

这是我的 test.mysite.com.pubxml 文件:

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
 <AfterAddIisSettingAndFileContentsToSourceManifest>AddCustomSkipRules</AfterAddIisSettingAndFileContentsToSourceManifest>

    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>\\server\websites\test.mysite.com</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
  </PropertyGroup>

  <PropertyGroup>
    <UseMsDeployExe>true</UseMsDeployExe>
  </PropertyGroup>

  <Target Name="AddCustomSkipRules">
    <Message Text="Adding Custom Skip Rules" />
    <ItemGroup>

      <MsDeploySkipRules Include="SkipThumbs">
        <SkipAction>Delete</SkipAction>
        <ObjectName>filePath</ObjectName>
        <AbsolutePath>$(_DestinationContentPath)\\images\\thumbs\\.*</AbsolutePath>
        <Apply>Destination</Apply>
      </MsDeploySkipRules>

    </ItemGroup>
  </Target>
</Project>

【问题讨论】:

    标签: deployment visual-studio-2013 publish


    【解决方案1】:

    刚刚发现&lt;MsDeploySkipRules&gt;在设置&lt;WebPublishMethod&gt;FileSystem&lt;/WebPublishMethod&gt;时不起作用。应该是&lt;WebPublishMethod&gt;MSDeploy&lt;/WebPublishMethod&gt;,并且必须在服务器中配置MSDeploy。

    我按照http://www.leniel.net/2014/05/using-msdeploy-publish-profile-pubxml-to-create-an-empty-folder-structure-on-iis-and-skip-deleting-it-with-msdeployskiprules.html#sthash.QN1BSQN1.dpbs中的说明进行操作

    并且跳过我指定的文件夹的删除已完成。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多