Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild calling incorrect version of csc.exe

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?

like image 318
ilivewithian Avatar asked Sep 17 '25 15:09

ilivewithian


1 Answers

MSBuild uses a Toolset of tasks, targets, and tools to build an application. Typically, a MSBuild Toolset includes a microsoft.common.tasks file, a microsoft.common.targets file, and compilers such as csc.exe and vbc.exe. To ensure MSBuild invokes the correct C# compiler (csc.exe), specify the Toolset in the ToolsVersion attribute on the Project element in the project file. The following example specifies that the project should be built by using the MSBuild 4.0 Toolset.

<Project ToolsVersion="4.0" ... </Project>

More information pertaining to the ToolsVersion attribute can be found here: http://msdn.microsoft.com/en-us/library/78f4aasd.aspx

like image 199
Anthony McGary Avatar answered Sep 22 '25 06:09

Anthony McGary