visual-studio-2010teamcitywebdeployapp-offline.htm

Ignore file from delete during WebDeploy


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.


Solution

  • 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>