Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coming up with a better ASP.NET deployment strategy

At work we currently use the following deployment strategy:

  • Run a batch script to clear out all Temporary ASP.NET files
  • Run a batch script that compiles every ASPX file into its own DLL (ASP.NET Web Site, not Web Application)
  • Copy each individually changed file (ASPX and DLL) to the appropriate folder on the live server.
  • Open up the Deployment Scripts folder, run each SQL script (table modifications, stored procs, etc.) manually on the production database.
  • Say a prayer before going to sleep (joking on this one, maybe)
  • Test first thing the next morning and hope for the best - fix bugs as they come up.

We have been bitten a few times in the past because someone will forget to run a script, or think they ran something but didn't, or overwrote a sproc related to some module because there are two files (one in a Sprocs folder and one in a [ModuleName]Related folder) or copied the wrong DLL (since they can have the same names with like a random alphanumeric number generated by .NET).

This seems highly inefficient to me - a lot of manual things and very error prone. It can sometimes take 2-3 or more hours for a developer to perform a deployment (we do them late at night, like around midnight) due to all the manual steps and remembering what files need to be copied, where they need to be copied, what scripts need to be run, making sure scripts are run in the right order, etc.

There has got to be an easier way than taking two hours to copy and paste individual ASPX pages, DLLs, images, stylesheets and the like and run some 30+ SQL scripts manually. We use SVN as our source control system (mainly just for update/commit though, we don't do branching) but have no unit tests or testing strategy. Is there some kind of tool that I can look into to help us make our deployments smoother?

like image 555
Wayne Molina Avatar asked Oct 04 '11 13:10

Wayne Molina


3 Answers

I did not go through all of it, but the You're deploying it wrong series from Troy Hunt might be a good place to look at.

Points discussed in the series :

  • Config transforms
  • Build Automation
  • Continuous Integration
like image 58
marco-fiset Avatar answered Nov 16 '22 02:11

marco-fiset


We have four stages before it can be deployed.

  • Development
  • QA
  • UAT
  • Production

We have build scripts (inside bamboo build server) running against QA and against UAT. Our DBA is the only person who can run create scripts against QA, UAT, and PROD. Anything that goes from QA -> UAT is like a test run deployment. UAT gets reverted by copying the production systems down again.

When we release into Production we just create a whole new site and point it at the UAT database and test that environmentally it is working fine. Then when this is working good we flick the 'switch' and point the production IIS record at the next site, and change the DB connection to point at Prod DB.

Because we are using a completely diff folder structure all of our files get copied up so there is no chance of missing one. Because we have had test runs of deployment into UAT we know we haven't missed a DB script (DB Scripts are combined into one generally). Because we have tested a shadow copy of the IIS website we know that environmentally it should work. We can then do all this set up during the day - and then do the final switch flicking at midnight or whenever - reducing the impact on devs.

tl;dr; Automated build and deploy; UAT system for test running deployment; Deployment during work hours; Flick switch/run DB update at midnight.

like image 32
Dave Walker Avatar answered Nov 16 '22 00:11

Dave Walker


I am a developer for BuildMaster, a tool which can very easily automate the steps you have outlined above, and we have a limited version free for a team of 5 developers.

Most of your pain points will disappear the moment you set up the deployment automation - mainly the batch script execution and the file-by-file copying. Once you're fully automated, you can even schedule the deployment for night time and only have to worry about it if there's an error in the process (you can set up a notifier for a failed build).

On the database side, you can integrate your database with BuildMaster as well and if you upload the scripts into the tool it will keep track of which ones were run against which database.

To see how to set up a simple web application deployment plan, you can run one of the example applications included. You can also check out: http://inedo.com/support/tutorials/lunchmaster/part-1 to see how to create one yourself - it's slightly outdated since we've made it even easier to get started out-of-the-box but the main concepts are the same.

like image 45
John Rasch Avatar answered Nov 16 '22 01:11

John Rasch