在WebDeploy期间忽略删除中的文件 [英] Ignore file from delete during WebDeploy

查看:122
本文介绍了在WebDeploy期间忽略删除中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TeamCity通过msbuild和WebDeploy构建和部署MVC应用程序的集合.

I'm using TeamCity to build and deploy a collection of MVC Applications via msbuild and WebDeploy.

在解决方案构建/部署之前的步骤中,我将app_offline.htm复制到deploy目录,以便可以执行SQL更新和其他Web/解决方案管理步骤,包括构建.

In a step previous to my solution build/deploy, I copy an app_offline.htm to the deploy directory so that I can perform SQL updates and other web/solution management steps including the build.

WebDeploy中的一项设置是删除项目中未包含的文件或运行站点不需要的文件.每次都会删除我的app_offline.htm文件.虽然我知道这是理想的结果,但是有没有办法在部署时从部署目录中删除此文件呢?

One of the setting in the WebDeploy is to delete files that aren't included in the project, or not needed to run the site. This deletes my app_offline.htm file each time. While I understand this is kind of the desired result, is there a way to exclude this file from being deleted from the deployment directory upon the deploy?

我尝试添加带有ExcludeFromPackageFiles选项的ItemGroup,但是没有结果.

I've tried adding an ItemGroup with the ExcludeFromPackageFiles option, with no results.

推荐答案

我遇到了类似的问题,即使它们不属于项目,也希望将缩小的javascript文件保留在部署包中.

I had a similar problem, wanting to keep minified javascript files in the deployment package even though they're not part of the project.

我为此添加了一个自定义MSBuild目标,该目标对我而言有效:

I added a custom MSBuild target for this, that works for me:

<!-- ====== Package the minify files ===== -->

 <PropertyGroup>
  <CopyAllFilesToSingleFolderForPackageDependsOn>
    CustomCollectFiles1;    
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  </CopyAllFilesToSingleFolderForPackageDependsOn>
 </PropertyGroup>

 <PropertyGroup>
   <AfterAddIisSettingAndFileContentsToSourceManifest>
    MakeEmptyFolders
   </AfterAddIisSettingAndFileContentsToSourceManifest>
 </PropertyGroup>

<Target Name="CustomCollectFiles1">
  <ItemGroup>
   <!-- =====Controls\Javascript folder ==== -->
    <_CustomFilesForRootFolder Include=".\Controls\Javascript\*.min.js">
    <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)    </DestinationRelativePath>
   </_CustomFilesForRootFolder>
  <FilesForPackagingFromProject Include="%(_CustomFilesForRootFolder.Identity)">
    <DestinationRelativePath>.\Controls\Javascript\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
  </FilesForPackagingFromProject>
 </ItemGroup> 
</Target>

这篇关于在WebDeploy期间忽略删除中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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