Visual Studio 2013发布MVC Web应用程序 - 防止从服务器删除文件夹

问题描述:

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

这是MS部署命令我使用:

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> 

就发现<MsDeploySkipRules><WebPublishMethod>FileSystem</WebPublishMethod>设置不起作用。它应该是<WebPublishMethod>MSDeploy</WebPublishMethod>并且必须在服务器中配置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

发现

我遵循的指示和我跳过指定的文件夹的缺失完成。