Productivity

How to handle builds & deployments for multiple environments in .NET

I came across a situation a while back, where I needed to setup a build process for a Visual Studio 2008 solution that contained multiple projects:

  • A bunch of Console Applications,
  • A mobile app (targeted at an enterprise-class rugged Windows Mobile 6.5 device to be used on field),
  • A desktop Windows Forms application &
  • An ASP.NET web application.

We have 3 server environments: Dev, QA & Production on which each of these applications should be capable of running. (Except for the mobile app, which will run on its own SQLCE database file sitting on each hand-held unit). What I needed to come up with, was a way to manage the environment-specific configuration info in a manner that let me do a single build, and “apply” the right set of configuration data according to where I was doing the deployment.

The direct way to do this would be to use the VS Solution/Project Configuration functions. You would create one configuration for each environment. Then you would set up a pre-build event like <code> copy “$(ProjectDir)$(ConfigurationName).<<configfilename>>” “$(ProjectDir)$(OutDir)<<configfilename>>” /Y </code> to copy the right config file over to your build output directory. You can check out this excellent (albeit really old, considering this is VS 2008!) article from Bil Simser –
http://weblogs.asp.net/bsimser/handling-multiple-environment-configurations-with-net-2-0
or this one from Scott Hanselman –
http://www.hanselman.com/blog/ManagingMultipleConfigurationFileEnvironmentsWithPreBuildEvents.aspx

The disadvantage here is that you need to do a build with the appropriate configuration selected, in order to get the right set of files selected. I would prefer to have a single build output file, like a TAR/ZIP archive, which includes all the config files for all environments. Then when I deploy/unpack it to the right environment, I want to deploy the right config files based on an argument that I’ll pass into my deployment script. Personally, that makes it easier to control for me, rather than pick the right build configuration on the VS IDE every time. It also enables me to do everything on the command-line too if I want, which is good to have.

Being a .NET newbie, I didn’t have the time to figure out Nant (which is free & open-source btw), so I used Visual Studio’s pre-build & post-build events to make things work the way I needed them to. Here is how it went.

(more…)

Setting up a VPN using LogMeIn Hamachi

Here is my requirement:

Comm Situation

 

  • I have regular servers running a bunch of enterprise apps sitting in a customer data center, BUT they do not have full access to the enterprise WAN (due to various management-level battles and project permissions).
  • The servers have access to the Internet only via a regular home-use-type modem sitting next to the rack. So the team needs to use TeamViewer/VNC/LogMeIn to hook up with them.

Obviously, not ideal! Where I work, we can’t afford to get a broadband line with a static IP for the servers, which is what is needed to set up a proper VPN with a firewall. In the meantime, LogMeIn Hamachi is what I use to access my server apps straight from my workstation. Hamachi can be used to create a virtual private network (VPN) over the Internet. It installs an adapter on every member of the network, which lets it create a relay tunnel to push traffic from point-to-point. (more…)