views:

39

answers:

2

Hi All,

I have a project that currently compiles happily on my dev machine using VS 2010 (presumably using MSBUILD v4.0), but it fails under MSBUILD v3.5 in Team City (running on a VM based on Win 2003 server w/ .NET 2, 3.5 and 4 installed). This project is newly upgraded to 2010, and is now failing on the CI build. I've Googled this and tried everything obvious (plus a few things that didn't make sense) and nothing affects the outcome.

The project fails with a sequence of errors like this:

error CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)

There are numerous other projects in the solution that use System.Core, System.Data.Linq and System.Xml.Linq and they all seem to compile with no problems. The project in question is a web application, and it has the following settings in its configuration/system.web/compilation/assemblies section:

    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

Plus the following in the same file:

<system.codedom>
  <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
      <providerOption name="CompilerVersion" value="v3.5"/>
      <providerOption name="WarnAsError" value="false"/>
    </compiler>
  </compilers>
</system.codedom>

The project in question is, IIRC, the only project in my solution that is both a WebApplication and is getting post-processed by PostSharp (v1.5). PostSharp is configured in the .csproj like so:

<PropertyGroup>
  <DontImportPostSharp>True</DontImportPostSharp>
  <PostSharpUseCommandLine>True</PostSharpUseCommandLine>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(POSTSHARP15)\PostSharp-1.5.targets" />

I'm not sure how this could be related, but it's there just in case.

Any ideas on what's causing this error or on how to work around the issue?

TIA

A: 

Did you switch the MSbuild to v4.0 on teamcity? I don't think you can build a 2010 project with .Net 4.0 using the MSbuild 3.5 on teamcity.

MikeU
Hi Mike, in actual fact I've opted to keep the framework on 3.5 and am able to build my toolset="4.0" files as though they were toolset="3.5" (the framework adapts itself accordingly)
Andrew Matthews
A: 

Solved:

Adding the references to the web.config file is pointless, because PostSharp enters the picture before ASP.NET has performed any compilation of its own, so an absence of a reference to System.Core reference causes the system to fail (I'm not sure why).

The solution is to manually edit the csproj file for the failing project and manually add a reference to System.Core to the project. You cannot do this from the solution explorer because it disallows adding references that should be added automatically by MSBUILD.

Still not sure why it failed in the first place, but at least it now compiles and passes tests again.

Andrew Matthews