02 September 2010

Version Control and Continuous Integration with Visual Studio

Some notes on setting up this combo:
  • Subversion Version control
  • Development with Visual Studio, integrated with the version control with Visual SVN
  • Continuous integration with Team City
So here we go:
Version (Subversion) Control Server:
  • Install Visual SVN Server
    • Create a user
    • Use secure connections
    • Setup a repository eg [Project Name] with trunk etc
Development Machine:
  • Install Visual Studio if not already
  • Setup Subversion Server management with Tortoise
    NB to setup local working copy:
    • Connect using Repro Browser URL format described here and enter username/pw
    • Checkout a working copy over your existing directory NB: Use the ‘same’ folder ie. checkout [My Project\trunk] to [My Project\trunk] and it’ll warn its not empty
    • Right click on this (now version controlled) parent and click Tortoise SVN/Add
  • Install version control (Subversion) integration with Visual SVN Client (it’s well worth the modest price for the avoidance of hassle)
  • Install Web Deployment Projects
Continuous Integration Server:
  • Install target .Net Framework e.g. 4.0
  • Install Windows SDKs; copy MSBuild files from your dev machine and alter the MSBuild file (see this post)
  • Install Team City (Web Service and Build Agent)
    • NB: I had some issues with The Web Service not finding the Agent, but allowing the agent’s port in the firewall then adding it via Agents/Agent Push fixed it
      You may need to install psexec.exe first (I had to rename it to lower case)
  • Setup a project, build configuration
    • Version Control Settings: Auto on the server; set Checkout directory e.g. C:\TeamCity\[project name].[build config]
    • Build Step:Runner type Visual Studio; Solution  file is relative to the repository path so probably something like \trunk\[Project Name]\[Project Name].sln; (Build) Configuration e.g. Debug
    • VCS build trigger: when changes are checked in it will automatically fire a build.
  • Install Web Deployment Projects
  • You also need MVC if you're using it: http://www.asp.net/mvc/mvc3
Once you’ve got it building then it’s time to add a deployment project to deploy it to the IIS server
Web Deployment Projects
  • Install WDP on both your development and build server from here if you haven’t already (it’s used by MSBuild).
  • Right click on the web project to be deployed and select ‘Add Web deployment project’ and name it accordingly. I use [project name].Deploy
  • Ensure you have sufficient Configurations in Build/Configuration Manager. e.g. I use:
    Debug: local development
    Alpha: LAN development server
    Beta: ‘Live’ testing
  • In Team City you need to have a config related to each Build Configuration:
    • Go to Project Configuration, Click 'Create Template from Configuration'
    • Edit the template to tokenise some values:
      • Version Control Source:enter %checkout.directory% instead of the existing value, you'll then replace the original value in the TC Build Config for the build e.g.  Release
      • Build Step: Enter %configuration.name% in Configuration
      • Build Triggering: remove the build trigger, as you'll re-create them in the derived configurations.
    • Edit the original TC configuration to set the build parameters of the tokenised values e.g.:
      • checkout.directory: C:\TeamCity\[projectname].Debug
      • configuration.name: Debug
      • Build Trigger: e.g. create a VCS auto build
    • Create a derived 

No comments:

Post a Comment