VS2010, .NET 4.0, MSBuild - problem with aspnet_compiler


I've run into a problem after upgrading one of our projects to .NET 4.0.

It fails during compilation in Team City with the following error message:

"web.config(19, 0): error ASPCONFIG: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive."

The attribute is set on the compilation element in web.config:

<compilation debug="true" targetFramework="4.0">

I checked the full build log and I found this for the aspnet_compiler:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v /ProjectName.csproj -p D:\BuildAgent\work\fe9e7aef8b7978f4\SolutionName\ProjectName-u -f -c -d .\TempBuildDir\

The build configuration is set up as:
Runner: MSBuild
MSBuild version: Microsoft .NET Framework 4.0
MSBuild ToolsVersion: 4.0

The msbuild script also has ToolsVersion="4.0" specified on the Project element.

The project builds perfectly fine if I use the sln runner, where the full build log then contains:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /ProjectName.csproj -p D:\BuildAgent\work\fe9e7aef8b7978f4\SolutionName\ProjectName-u -f -c -d .\TempBuildDir\

The build is set up in the script as:

<MSBuild Projects="SolutionName.sln" ContinueOnError="false" Properties="Configuration=$(Configuration)">
      <Output ItemName="BuildOutput" TaskParameter="TargetOutputs" />

so it's just plain building the solution with MSBuild. The reason I want it to work with MSBuild instead of going with the sln runner is that we have deployment set up in the script as well

Any idea how to fix this, or is it a bug in Team City? (Still on 5.1, but in the process of getting it up to 5.1.2 today)

Message was edited by: Geir-Tore Lindsve. Added some additional info

What was the version of TeamCity? Have you updated to 5.1.2?


I finally discovered the culprit for this issue yesterday (sorry for not closing this question).

It was a VS2010 Web Deployment Project in my solution that was not correctly upgraded from the VS2008 version and still had ToolsVersion=3.5 specified. Everything worked fine after fixing this in the project file.


Please sign in to leave a comment.