views:

31

answers:

2

I am trying to use nant 0.90 with a visual studio 2008, .net 3.5 project. The nant script is being called by team city. Nothing too complex here.

<?xml version="1.0"?>
<project name="IPSA System" default="build" basedir=".">
  <property name="nant.settings.currentframework" value="net-3.5"/>
  <msbuild project="FS.IPSA.WebAdmin\FS.IPSA.WebAdmin.csproj">
    <arg value="/property:TeamOutPath=Release\FS.IPSA.WebAdmin" />
    <property name="TeamOutPath" value="Release\FS.IPSA.WebAdmin" />
  </msbuild>
</project>

The problem I'm having is that nant is insisting on calling the .net 2.0 complier rather than the 3.5. I thought that putting the nant.settings.currentframework value into the script was supposed to force the framework version. This doesn't seem to be the case. What else might be causing the problem?

A: 

Maybe the msbuild task is unable to build vs.net 2008 solutions (e.g. wrong version of msbuild.exe is called).

What about using something like this:

    <!-- msbuild from .net 2.0 is unable to build vs.net 2008 solutions. Let's try to find .net 3.5 version of msbuild -->      
    <property name ="msbuild.exe" value="msbuild"/> <!-- default-->
    <property name="windows.dir" value="${environment::get-variable('windir')}"/>
    <property name="net3.5.dir" value="${windows.dir}/Microsoft.NET/Framework/v3.5"/>
    <if test="${directory::exists(net3.5.dir)}">
        <property name="msbuild.exe" value="${net3.5.dir}/msbuild.exe"/>
    </if>

    <!-- current nant msbuild task is unable to build VS.NET 2008 solutions -->
    <!-- let's try run correct msbuild.exe via the exec task -->
    <exec program ="${msbuild.exe}" verbose="true">
        <arg value="/property:TeamOutPath=Release\FS.IPSA.WebAdmin" />
        <arg value="FS.IPSA.WebAdmin\FS.IPSA.WebAdmin.csproj"/>
    </exec>
Martin Vobr
A: 

In the end it turns out that nant was not casuing the problem, it was calling the correct version of msbuild, but msbuild was calling the wrong version of csc.exe. I've not tracked down why it's doing it, but it looks like it's msbuild, not nant.

ilivewithian