Let’s kick the blogging back off with a bang…  Back to programming…

Lately, I’ve had a heck of a time trying to create decent deployment projects for web projects in Visual Studio 2008.  We use Team Foundation Server to do our build, but for some reason, it doesn’t copy all of the files in the web project to the drop location for deployment.  Things like PDFs and other documents that are part of the system do not get put in the drop directory at all.  I do NOT feel like creating scripts for all of the ‘extra’ files, especially since they can change with any given release (yes, I know that it’s not the solution one should use, but finding 10 minutes to do anything lately is tough). 

The other, much bigger problem is that we have when deploying our sites is the web and library configurations for each stage of deployment.  I had written a script with a tool called ‘Automise’ but trying to get that thing to work completely frazzled me.  The idea is cool, but to subdivide the projects caused the variables to get completely unmanageable.

There has got to be a better way to handle deployments than this!

Well, today I found a fairly decent way to build my deployments.  I had seen the Visual Studio 2008 Web Deployment Projects on Scott Guthrie’s blog, but really hadn’t paid attention to the add-on.  It seemed ‘overly simple’.  Turns out ‘overly simple’ was exactly what I needed!

The Visual Studio Web Deployment Projects solved both problems VERY handily.  First off, it copied the site CORRECTLY to a drop location.  No more, ‘the PDF didn’t get updated!’ to worry about.  The other part is that the deployment project handles building the web config file fairly cleanly.  In fact, the web config handling is what prodded me to get off my rear and actually write a bit!

There are a couple of tricks that make the web config MUCH smoother.  One of them is how the settings can be created.  The Web Deployment project can replace any section of the web config with a section in a file that is specified.  To set the section to be replaced and the name of the file with the section TO replace it, you go to the Web Deployment Project’s properties and go to the Deployment item in the tree.  There you can set the ‘Enable Web.config file section replacement’. 

The format for specifying the section of the web.config to be replaced by a file is: section=filename;  It’s not mentioned anywhere, but you can get to the subsections by going section/subsection.  This is very useful for setting the library sections of applicationSettings.  We use applicationSettings/CompanyName.Bll and applicationSettings/CompanyName.Dal to replace the BLL and DAL library settings.  I don’t know how far into the sub sections one can get, but just being able to get to the subsection helps.

Unfortunately, the files for the config replacement cannot be part of the Web Deployment project.  To me, that would be a logical place for them.  What we did find, though, was that the files can be put into the Web Applications directory!  If you specify just a filename in the section=filename setting, filename will be found in the root directory of the web project.  It is easy to specify sub directories by going section=subdirectoryfilename.  We ended up creating ConfigurationsBuildTypes subdirectories in the web project.

This makes it FAR easier to deploy.  Plus, the Web Deployment Project has some MSBuild tasks that should make it fairly easy to send the projects directly to our servers.

Pretty cool, eh?


2 thoughts on “Visual Studio 2008 Web Deployment Projects are cool (and have some gotchas!)

  1. I hate it when ou’re working with something that doesn’t work the way it should and you just knowthat someone somewhere has created the solution but you just can’t find it.  I find this all the time with AutoCAD development, and time for programming is the hardest thing to find these days and everyone wants it done yesterday.  I get such great responses from programmers on the discussion forums for Acad.  There’s always someone out there who has the time to tinker and loves it so much they’ll do it for free.  And I always learn something along the way.
    Glad to see you back!

  2. 🙂  Sounds like the AutoCAD community is a good group.
    It’s great to see your blog coming along!  Are you feeling any better? 
    There will be more blog entries soon!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s