Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

We are setting up TeamCity to do auto deployments. I have an MSBuild build step that deploys to the \DotNet folder (the aspx files), and in a separate build configuration I have another MSBuild build step that deploys to the root (the asp files).

I want to allow MSDeploy to delete unnecessary files, e.g. 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 wipe the \DotNet subfolder.

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

like image 985
Michael12345 Avatar asked Mar 25 '13 04:03

Michael12345


3 Answers

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

When deploying to the root folder of an application using the MSDeployPublish target via MSBuild, by default, extra subfolders that happen to be on the filesystem of the target IIS server are deleted.

To avoid this, I simply moved the contents of my DotNet folder to a totally separate location under C:\InetPub, but retained my original virtual folder/application structure under IIS Mgr. Of course!

Now I can publish to either location as much as I please, and one won't try and delete the other because one is no longer a filesystem subfolder of the other.

If anything - this highlights how primitive our earlier folder structure was, and what a doofus I am for not realising.

like image 139
Michael12345 Avatar answered Sep 28 '22 17:09

Michael12345


I'm not exactly sure what you're looking for here. Are you trying to delete all the files from within the dotnet subfolder but keep the folder? Are you trying to have the delete operation never delete anything from the dotnet folder? The msdeploy sync operation is pretty smart. msdeploy will move all of your marked project assets, so assuming you don't delete the files in the dotnet folder, then you should be fine.

If you just want to exempt the dotnet folder from any delete actions, as if it were a not part of your project at all, but its in a subfolder the web server and you want to not touch it, then I would suggest using the skip option in msdeploy with wildcards. I've only used it for files, but it should work for folders too. It goes like so:

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

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

Search the page for -skip:skipAction=

like image 31
Dan Csharpster Avatar answered Sep 28 '22 16:09

Dan Csharpster


You could also add a skip setting with name of the folder you wish to not by synced, like in the following 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 the example from the answer to this question.]

like image 44
Kenny Evitt Avatar answered Sep 28 '22 17:09

Kenny Evitt