Automate Build script from Batch to MSBUILD/NANT

434 views Asked by At

I am trying to automate a build process for a C# (vs2008) solution.

The build script is written in a Batch script which I want to change. We use Clearcase as the CM system. I have searched some tools such as MSBUILD, NANT.

Any suggestions which is a better solution like a sample script in MSBUILD and NANT?

I have not seen any sites where MSBUILD and NANT is documented well or any good tutorial about each task description.

Where I can learn MSBUILD or NANT either of them and write script from scratch?

1

There are 1 answers

14
MichaelS On

There is a third way which I prefer. You can also use devenv.com. It's faster than NANT, doesn't require NANT bins and works on any machine with VS installed. You also avoid possible errors with MSBUILD (http://support.microsoft.com/kb/964125).

Just use %path_to_devenv.com%\devenv.com "%path_to_sln" /<buildoption> BuildConfig

In my case it's

%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com "C:\Projects\XYZ\xyz.sln" /rebuild Debug

This way it's guaranteed that your project will be build exactly the same way as it's being built in Visual Studio.

EDIT:

Now that we know how how much there is to do, I'll try to give an outline how you can setup the whole system for automated build controll.

  1. Set up your repository (I hope this is already done - tell me if not)
  2. Install and set up Jenkins (https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins) including users, ClearCase-Credentials, plug-ins for ClearCase, MSBuild, etc. (all of them can be found in the Jenkins plug-in interface) - this is the biggest peace of work
  3. Create and set up a new project in the jenkins interface (name, working directory, etc.)
  4. Tell jenkins to use source code management (e.g. subversion module), enter the ClearCase repos to use, set the desired behavior of the source code management
  5. Set a build trigger (I recommend checking the source code management each minute: * * * * *)
  6. Add a build step and select "Build a Visual Studio project or solution using MSBuild" - this option should appear after installation of the MSBuild plugin (https://wiki.jenkins-ci.org/display/JENKINS/MSBuild+Plugin)
  7. Set the path to the .sln file (you have checked it out from your repository)
  8. Add more optional arguments if desired (eg /p:Configuration=Release or Debug or whatever http://msdn.microsoft.com/en-us/library/vstudio/ms164311%28v=vs.110%29.aspx)
  9. Play around untill it works

Btw., I recommend to put all external dlls into your repository.