0

NOTE: This is for a Visual Studio Web Site Project and NOT a Web Application

I am using web deploy to push changes from my development machine to my staging server. I would like to push any files that are different to the staging server except for one particular file (lets call it myFile.whatever)

So far I have tried editing the C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe.config file to look like so:

<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727" />
    <supportedRuntime version="v4.0" />
  </startup>
  <rules> <------------ ADDED THIS NODE
    <rule name="skipConfig" type="Microsoft.Web.Deployment.DeploymentSkipRuleHandler"
          objectName="filePath" skipAction="Delete" 
          absolutePath="C:\inetpub\wwwroot\MyProject\myFile.whatever"/>
  </rules>
</configuration>

But it is still overwriting the file in question on my staging server. I started by editing the msdeploy.exe.config on my dev machine and when that didn't work I updated the msdeploy.exe.config on my staging server as well, but again, still not working.

Am I going about this wrong? Any suggestions on preventing this file from being overwritten?

Abe Miessler
  • 82,532
  • 99
  • 305
  • 486
  • 3
    What is getting overwritten on the staging server that you need to prevent? Have you considered setting up web.config transforms so that you can deploy your staging server settings there? – Dillie-O Dec 17 '13 at 23:44
  • There are about 20 elements in the web.config that are being changed. I have considered transforms, but I would rather just not copy the file. – Abe Miessler Dec 17 '13 at 23:45
  • Transforms are pretty easy and the right way to go with this. XDT is pretty straightforward too. – Mike Cheel Dec 17 '13 at 23:51
  • Ok, I'm open to that. Just out of curiosity, why is it better to transform vs. not copy? – Abe Miessler Dec 17 '13 at 23:52
  • 1
    If you decide to change things later (or potentially don't have access to the server after deployment) you can manage it better from within the solution itself. You can also setup as many web.config transforms as you want, if you need to specify different servers. – Dillie-O Dec 17 '13 at 23:53
  • @Dillie-O - can I use web.config transforms if I am working with a web site (rather than a web application)? – Abe Miessler Dec 18 '13 at 00:14
  • @MikeCheel/@Dillie-O, I did some poking around and the only way I found to do web.config transforms on a web site (not a web application) was this link: http://andrewtwest.com/2010/02/25/using-web-config-transformations-in-web-site-projects/ This seems like a pretty nasty hack. After reading the article it seems like it would make more sense to simply not copy over the file, rather than trying to piece together this giant hack and explain it to future programmers. Thoughts? – Abe Miessler Dec 18 '13 at 00:43
  • I didn't realize it was web site (vs application). I would probably go with Nathan's answer then. – Mike Cheel Dec 18 '13 at 01:54
  • I didn't realize as well. I agree with solution below. – Dillie-O Dec 18 '13 at 13:13
  • @MikeCheel/@Dillie-O, there is no way that Nathan's answer could work with a web site project. – Abe Miessler Dec 18 '13 at 16:51
  • Why wouldnt the ExcludeFromProject thing work? – Mike Cheel Dec 18 '13 at 17:03
  • There are no project file in web site projects, so there is simply no where to add `ExludeFromProject` – Abe Miessler Dec 18 '13 at 17:10

2 Answers2

1

Since transforms are painful with web site projects you might be able to use this method: http://blogs.msdn.com/b/webdev/archive/2010/04/22/web-deployment-excluding-files-and-folders-via-the-web-application-s-project-file.aspx

Nathan Prather
  • 2,098
  • 1
  • 18
  • 15
  • This article is focused towards web applications and not web site projects. What in there do you think would work in my situation? From what I can tell his advice is to modify the project file which is impossible in my situation because web site projects do not have project files. I do appreciate the suggestion, but I had to -1 this answer because it simply won't work for web site projects. Please don't take it personally. – Abe Miessler Dec 18 '13 at 16:24
  • Sorry, I just tested this and you are correct there is no project file with web sites projects... At this point I would recommend that you convert the web site project to a web application project. I've done this before in the past and it's well documented and only took me a couple hours. Scott Gu has a good article on how to do this... It's also discussed here: http://stackoverflow.com/questions/650875/exclude-files-from-web-site-publish-in-visual-studio – Nathan Prather Dec 18 '13 at 22:22
  • Ok. Any chance you could delete this answer so I can delete the question? – Abe Miessler Dec 19 '13 at 04:53
  • I think this information could be helpful to others, so there's no harm in leaving it... – Nathan Prather Dec 30 '13 at 02:33
  • You yourself have admitted your answer does not apply to my question. Suggesting I migrate to an entirely different project type isn't really an answer... – Abe Miessler Dec 30 '13 at 05:05
  • Sorry you feel that way Abe. Best wishes – Nathan Prather Jan 05 '14 at 17:47
0

As stated in the comments, what you would normally do is to have a base Web.config file, then one specific for debug and one specific for release. The debug or release portion would add/override the base one with things that are particular to this scenario. This way you can just upload both and everything will work fine.

To understand more about web.config transformation, please refer to: http://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx

Andre Pena
  • 56,650
  • 48
  • 196
  • 243