Using MsBuild with TeamCity, (dotnet 3.5). Look Ma no Visual Studio!

by Jon 12. September 2010 01:08

I am currently moving our TeamCity to a different Virtual Server using this post by Mikael Henriksson.  Its is a fresh server install I thought it would be a great excuse to blog the steps you need to take to get MsBuild Working on your TeamCity.  In my previous post I described how to get started with Team City in under 5 Minutes, this short post follows on from that.

MsBuild gives you more flexibility when compiling your projects/solution.  However it isn't especially clear from documentation how you get your server configured to use MSBuild, or even what a basic MsBuild file will look like.  I got there painfully through trial and error, if you want to get up and running with MSBuild in TeamCity without having to install Visual Studio 2008 at all on your server follow the following six steps:

1. Install the MsBuild Community Tasks via the Msi Installer

2. Download an Install Windows SDK for Windows Server 2008 and .NET Framework 3.5 on your server.  During the install you only need to Select the DotNet Development Tools to be installed.

3. Update the Build Targets so you can build the projects you work on your Server.  You need to copy the relevant files from your development machine to your Build Server by updating files in "C:\Program Files (x86)\MSBuild\Microsoft\"

4. Create the SolutionName.msbuild in the root directory of your solution, where SolutionName is the name of your solution.  You will need to update "SolutionName.sln" inside the MsBuild File to point at your solution.

<?xml version="1.0" encoding="utf-8"?> 

<Project DefaultTargets="ReleaseBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 

<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/> 

    <Target Name="ReleaseBuild"> 

        <Message Text="Building Your Solution"/> 

        <MSBuild Projects="SolutionName.sln" Targets="Rebuild" />



5. Go to your TeamCity and Edit your Build Runner so is is MsBuild, Change your Target to Release Build to Match the Target in the MsBuildFile, and update any command line parameters you may need. I am using an additional commandline parameter /p:OutDir=%teamcity.build.checkoutDir%\target\ which will compile a solution full of separate webapplications to a single target directory.

6. When you are happy you have the MsBuild File and TeamCity Build Runner correctly matching, commit your msbuild file to SVN.  Your Build will be automatically trigggered and MsBuild will be used to compile your solution instead of Visual Studio.  

This should give you alot more flexibility in future.  If this doesn't work for you or if I have made a mistake just leave me a comment and I will improve the post for others in future.

Tags: , ,

ddd | MsBuild | SVN | TeamCity.Net


Source Control is really blooming important

by Jon 3. May 2010 14:30

I cant stress enough how important and more importantly how useful source control is. If you are not using source control for your projects your essentially coding drunk. There is really no excuse as most is either free or very very cheap to get amazing features. Even if you are a one man or woman coder you should be using source control, as there are a whole heap of benefits:

  • You get a backup of your projects out of the box, if something goes wrong with your pc your safe (as long as your source controlling to a difference machine
  • You can see what changes you made and when and the reasons why, very useful when talking to customers or trying to find an issue
  • It makes you a better coder, with source control you get to see your changes and review them before you commit, removing mistakes or any test code you wrote
  • You can code with confidence, try ideas out and refactor with the confidence that you can always roll back to the last version you committed.
  • Patching, and quick fixes become a breeze. When you release a version of a website or system you can branch and keep a facsimile copy of what has been released. If you find a bug you can issue a bug fix rather than upgrading the entire system
  • If your company grows beyond one person, or you need to get development help you can easly hive some of the work out to anyone anywhere in the world

What source control system should we use?

There are a whole heap of source control systems available but we use a SVN based system. The other alternatives include SourceSafe, CVS, Team Server, and Mercurial (In the form of VisualHG), but we are sticking with SVN for now because it is stable and mature and works. As a source control system is the gatekeeper to your code it is important to have confidence in it, SVN is old enough for this and new enough to have lots of nice features. We will probably move to VisualHG in future, or team server but for now its not worth the leap.

So what software do you need to install?

Well it kind of depends what level of integration you want but here is a quick summary of what we use:

  • TortoiseSVN - Is the SVN client of choice for windows, it integrates into windows explorer and it is the only thing you need to get source control running. The best thing is it is mature, it is an opensource project but it has been running for years as SVN and before that for years as TortoiseCVS. This is the daddy of source control and its seamless integration into windows is fantastic. The best thing is you dont even need a server as you can run it against a file based SVN source repository without a server.
  • Visual SVN Server - SVN will work without a server, but if you want to simplify things and increase security this is a great server that just works. Again it is free but not open source, you dont need IIS as it will install its own version of Apache when it installs.
  • VisualSVN Client - If you want integrated source control in Visual Studio install this, it works in conjunction with tortoise so it is rock solid when it comes to stability. It has lots of great features when it comes to merging and branching, but it does cost. However at $49 a seat the cost is minimal to the advantages. You can download a free demo to see what you think, but you will make the small cost back in hours in increased productivity.
  • Stats SVN- Is a java application which generates html stats for a SVN repository. We run this every night to generate up to date web statistics on the project.

In summary install tortoiseSVN and see what you think, it will make you more productive.

Tags: , , , ,

development | SVN | vs2008 | windows phone 7

Powered by BlogEngine.NET
Original Design by Laptop Geek, Adapted by onesoft, and finally some tiny tweaks by JonAlb