6

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?

Michael12345
  • 2,520
  • 5
  • 23
  • 41

3 Answers3

6

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.

Michael12345
  • 2,520
  • 5
  • 23
  • 41
3

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=

Dan Csharpster
  • 2,662
  • 1
  • 26
  • 50
  • Thanks Dan - I have two separate MSBuild operations. One targets the root folder, one targets a subfolder. I don't want the one targeting the root folder to delete the DotNet subfolder or its contents. That -skip option looks good, but I am using MSBuild with a MSDeployPublish target so was hoping to be able to do this from the MSBuild commandline. – Michael12345 Mar 25 '13 at 19:59
  • Can you send me a sample of your msbuild command? I haven't used MsDeployPublish before but I have a theory that you should be able to stick MsDeploy parameters on the end of your command and it should take them. It doesn't make much sense for MS to chain MsBuild and MsDeploy together without giving you the ability to tweak MsDeploy in the command. This page looks kinda weird, but it looks like they were trying to do something similar: http://pastebin.com/qyKUBMqE – Dan Csharpster Mar 26 '13 at 14:37
  • Here is a link to another post I had with the same theory andhsowing my MSBuild command: http://stackoverflow.com/questions/15562817/how-can-i-pass-msdeploy-style-parameters-to-msbuild-via-the-commandline – Michael12345 Mar 26 '13 at 19:33
2

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.]

Community
  • 1
  • 1
Kenny Evitt
  • 9,291
  • 5
  • 65
  • 93
  • This option is only valid for msdeploy, not for msbuild /t:MsDeployPublish as described in the question. – Alex Weitzer Apr 09 '14 at 23:57
  • 2
    @AlexWeitzer, I don't see any mention of "msbuild /t:MsDeployPublish" in the question; it does include "I want to allow MSDeploy to delete unnecessary files ...". MSBuild can call MSDeploy. – Kenny Evitt Apr 10 '14 at 11:43