Question

I've read many articles and posts about executing NAnt scripts using TFS build, none of which have satisfied my needs.

I have a NAnt script that has been developed over the years to automatically build, test and deploy our websites to an internal staging and external demo environments.

Usually, the team has been so small that builds have been a manual process. The intention had always been to integrate this script into a CI environment.

Recently, we switched our source control to TFS 2012 with the aim of using TFS build with our existing NAnt script.

From what I can see so far, it is possible to execute a NAnt script with TFS build, but it is not possible to not specify a .sln file for TFS build to build first when creating a new build definition.

Ideally, I want NAnt to control the entire build/test/deploy process and for TFS Build to just butt out and just utilise the Checkin triggers TFS provides to trigger the NAnt build.

I've played with the idea of writing my own TFS checkin interceptor. Has anyone else solved this problem already?

Many thanks

Could anyone answering please stick the specific question being asked and not deviate by suggesting alternate (paid for or not) CI tools such as CCNet or TeamCity.

Cheers

Was it helpful?

Solution

Here is how you can do it:

1) Download Nant.exe from http://sourceforge.net/projects/nant/files/ and check-in the bin directory which has Nant.exe.

2) Create a msbuild file (say msbuild.proj) with following code(change Path) and check-in the file.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="RunNant">
        <Exec Command="bin\nant.exe; -buildfile:master.build build"/>
    </Target>
</Project>

3) Go to Process tab in your build definition and then go to "Items to Build" --> "Projects to Build" --> Select(icon on the right) --> Add --> Change "Items of type" to "MSBuild project files" and then select the .proj file you checked-in.

enter image description here

4) Run your build and it should work. See below log that shows that it ran the Nant build file.

Build started 12/31/2013 4:55:20 AM.
Project "C:\a\src\F\Test Projects\TestProject\msbuild.proj" on node 1 (default targets).
RunNant:
  bin\nant.exe; -buildfile:master.build build
  NAnt 0.92 (Build 0.92.4543.0; release; 6/9/2012)
  Copyright (C) 2001-2012 Gerry Shaw
  http://nant.sourceforge.net

  Buildfile: file:///C:/a/src/F/Test Projects/TestProject/master.build
  Target framework: Microsoft .NET Framework 4.0
  Target(s) specified: ; build 

   [solution] Starting solution build.

OTHER TIPS

We have a similar problem. For one of our projects we just want to run a DOS command for the build. What I did was create a custom build template that just runs a DOS command. The template has Arguments for the App to Run, App Arguments, and App Working Directory.

Here is what the whole template looks like in the designer.

enter image description here

Here is a list of our arguments

enter image description here

I have not used NAnt before but I am guessing you can run it from a DOS command. You should be able to pass in your .sln as one of the parameters to your DOS command.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top