views:

70

answers:

2

I am using team city to call a nant script, currently this nant script is very simplistic and only calls an msbuild task on a single project in the solution.

The build is failing, it looks like msbuild 3.5 is being called, but it is incorrectly calling the csc.exe from the .net 2.0 folder. Since we are using .net 3.5 language features the compilation fails.

Looking at the csproj file, both the ToolsVersion and TargetFrameworkVersion are both set to use 3.5. What would be causing msbuild to pick the wrong version of csc.exe?

A: 

Do you have the 2.0 version of csc directly in your path, perhaps?

What happens when you run msbuild from a Visual Studio 2008 Command Prompt?

Jon Skeet
There is nothing in the path. If I run msbuild on the server it runs fine. There's a clue in there somewhere. Hmm, I guess it's either teamcity or nant and not msbuild after all.
ilivewithian
A: 

You can directly point which msbuild you want to use in nant script by declaring:

<!-- Initial path to use MSBuild from .NET Framework 3.5 -->
<property name="MSBuildApp" value="C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe" />

And then execute build via msbuild:

<exec failonerror="true" program="${MSBuildApp}" verbose="true">
        <arg value="${SlnDir}\${SlnFile}" />
        <arg value="/t:Rebuild" />
        <arg value="/p:Configuration=${SlnConfig}" />
    </exec>

Or you can point to proper .NET framework version when running NANT script:

nant CreateYouProjectTask -t:net-3.5 -buildfile:BuildYourProject.build

Leszek Wachowicz