Ignore file from delete during WebDeploy
Asked Answered
S

2

8

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.

Saccule answered 18/2, 2011 at 3:16 Comment(2)
Are you sure this is checked out? You could create a new MSBUILD target to put this file somewhere and then do another task to bring it back.Cluny
That works, but for the few seconds while the next build target is running, the site would be available for user to visit, which wouldn't be ideal if db scripts haven't run, or there was an error while publishing took place and we have to roll-back the site to a previous stateSaccule
M
0

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>
Manganate answered 22/6, 2011 at 20:23 Comment(1)
thank you, I will give this a try. Unfortunately I no longer work where I was when this issue arose, but I'm in the process of starting another project using the same principles, so I'll give it a shotSaccule
B
0

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.

Blackthorn answered 25/2, 2011 at 5:28 Comment(2)
I'm asking how to keep WebDeploy from removing the file from my publish directory once its done deploying. I already copy the file out to the directory prior to running WebDeploy. But, because the file does not exist in the deployment package, WebDeploy deletes it.Saccule
Yeah. I just thought if this is not achievable or so, there is another way to achieve the final goal. Nevermind anyway.Blackthorn
M
0

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>
Manganate answered 22/6, 2011 at 20:23 Comment(1)
thank you, I will give this a try. Unfortunately I no longer work where I was when this issue arose, but I'm in the process of starting another project using the same principles, so I'll give it a shotSaccule

© 2022 - 2024 — McMap. All rights reserved.