0

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?

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
SteveScm
  • 545
  • 1
  • 7
  • 15

1 Answers1

2

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.

MichaelS
  • 5,941
  • 6
  • 31
  • 46
  • Thanks but you have suggested me to compile the solution file . But I am asking about to automate the script and upgrade it so that I can connect it to CI tools like hudson. – SteveScm Nov 25 '14 at 12:13
  • Well, in this case you should stick to MSBUILD. There's no need to use NANT, MSBUILD is perfectly integrated into Jenkins (Hudson) as a build step. – MichaelS Nov 25 '14 at 12:17
  • Is it really a `.com` file extension? – JDługosz Nov 25 '14 at 13:08
  • Thanks Michael. I got 50% answer. Now please let me know the tutorial as I am starting bee in MSBUILD and sample script to get an idea. – SteveScm Nov 25 '14 at 13:14
  • @jdlugosz yes, its a .com file. – MichaelS Nov 25 '14 at 13:22
  • @shank7: no script needed. Just add a build step in the Jenkins project, select .NET build step, select a MSBUILD version in the drop down menu and insert the path to the .sln file. That's it. Tell me if you need help with jenkins. – MichaelS Nov 25 '14 at 13:24
  • ok Michael but there are a lot of step also like to copy some .dll to different location. I have to set some variable first before starting build. So for all this there is a script which I need to upgrade to latest Tech i.e. MSBUILD. Thats why I was asking any tutorial which illustrates me each and every task as per my requirement. – SteveScm Nov 25 '14 at 13:49
  • And Sure Michael after writing the script i need to connect it to CI tool and I will consult you for Jenkins.. :) – SteveScm Nov 25 '14 at 13:50
  • Please update your original question with relevant information and some sample from your current script. Now we can only guess what you are trying to do exactly which makes it impossible to provide a proper answer – stijn Nov 25 '14 at 14:57
  • I've edited my answer...tell me if something is unclear. – MichaelS Nov 26 '14 at 07:57
  • Although I think that it's not an inhuman task to replace SVN by ClearCase in your mind and to google for a ClearCase plug-in for Jenkins, I've updated my answer. – MichaelS Nov 26 '14 at 12:45
  • @Michael right Michael as I have worked on SVN too but my organisation works on Clearcase, so its hectic to migrate from VCS to another VCS. But sure SVN is more faster and easy to use. I love it. – SteveScm Nov 26 '14 at 12:48
  • But Still I am seeking the answer as MSBUILD tutorial with step-by-step which help me in framing build script. – SteveScm Nov 26 '14 at 12:49
  • Please update me on same as I have very less knowledge on MSBUILD – SteveScm Dec 04 '14 at 12:00