Prevent MSDeploy from (selectively) deleting folders on the target IIS server

I have an IIS web application with a structure similar to:

wwww.mysite.com file1.asp file2.asp \DotNet file3.aspx file3.aspx 

We create TeamCity for automatic deployment. I have an MSBuild build step that is deployed in the \ DotNet folder (aspx files), and in a separate build configuration, I have another MSBuild build step that is deployed in the root directory (asp files).

I want to allow MSDeploy to delete unnecessary files, for example. if I remove file2.asp from VCS, I want it to delete it from the target IIS server.

However, I DO NOT want it to destroy the \ DotNet subfolder.

Can I get something more granular than the "SkipExtraFilesOnServer" command line switch, or is it an all-or-nothing deal?

+6
source share
3 answers

It turns out the answer to my question was much simpler than I expected

When deploying to the root folder of an application using MSDeployPublish using MSBuild, by default, the extra subfolders located in the file system of the target IIS server are deleted.

To avoid this, I simply moved the contents of my DotNet folder to a completely different place under C: \ InetPub, but retained my original virtual folder / application structure under IIS Mgr. Sure!

Now I can publish anywhere as much as I want, and no one will try to delete another, because it is no longer a subfolder of the other's file system.

If anything - this emphasizes how primitive our previous folder structure is, and what kind of doofus I am for not understanding.

+5
source

I'm not quite sure what you are looking for here. Are you trying to delete all files from the dotnet subfolder, but save the folder? Are you trying to ensure that the delete operation never removes anything from the dotnet folder? The msdeploy synchronization operation is pretty smart. msdeploy will move all of your marked project assets, so assuming you are not deleting files in the dotnet folder, then you should be fine.

If you just want to free the dotnet folder from any removal actions, as if it weren’t part of your project at all, but it’s in a subfolder of the web server and you don’t want to touch it, I would suggest using the skip option in msdeploy with wildcards . I used it only for files, but it should work for folders as well. It looks like this:

  -skip:objectName=filePath,absolutePath=app_offline\.* 

There is documentation here: http://technet.microsoft.com/en-us/library/dd569089%28WS.10%29.aspx

Search page for -skip: skipAction =

+3
source

You can also add the skip parameter with the name of the folder you want to sync, for example, in the next msdeploy call

 msdeploy -verb:sync -source:contentPath="C:\Data\Personal\My Repo\MSDeploy\MultiSkip\Source" -dest:contentPath="C:\Data\Personal\My Repo\MSDeploy\MultiSkip\Dest" -skip:objectName=dirPath,absolutePath="DotNet" 

[I took an example from the answer to this question .]

+2
source

All Articles