Ignore file from delete during WebDeploy

若如初见. 提交于 2019-12-07 00:34:39

问题


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

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.

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?

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


回答1:


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

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>



回答2:


This other question " Custom app_offline.htm file during publish " suggests one possible way for the final result you describe:

I use my own

app_offline.htm_

file in the solution, which gets published. My deployment script then renames it (removing the trailing _) to make it active.

I can then run my db scripts/do whatever then rename the file bringing the site back.



来源:https://stackoverflow.com/questions/5037280/ignore-file-from-delete-during-webdeploy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!