升级到VS 2010后,Team City构建失败

时间:2010-06-21 04:59:55

标签: visual-studio-2010 .net-3.5 postsharp teamcity-5.1

我有一个项目,目前使用VS 2010(可能使用MSBUILD v4.0)在我的开发机器上愉快地编译,但它在Team City中的MSBUILD v3.5下失败(在基于Win 2003服务器的VM上运行w /安装了.NET 2,3.5和4)。该项目新升级到2010年,现在CI构建失败了。我用Google搜索了这一切并尝试了一切显而易见的事情(加上一些没有意义的事情)并且没有任何影响结果。

项目失败,出现一系列错误:

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

解决方案中有许多其他项目使用System.Core,System.Data.Linq和System.Xml.Linq,它们似乎都可以编译而没有任何问题。有问题的项目是一个Web应用程序,它的配置/ system.web / compilation / assemblies部分中有以下设置:

    <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"/>

在同一档案中加上以下内容:

<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>

有问题的项目是IIRC,我解决方案中唯一一个既是WebApplication又被PostSharp(v1.5)后处理的项目。 PostSharp在.csproj中配置如下:

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

我不确定这是如何相关的,但它就是为了以防万一。

有关导致此错误的原因或如何解决此问题的任何想法?

TIA

2 个答案:

答案 0 :(得分:7)

解决:

添加对web.config文件的引用是没有意义的,因为PostSharp在ASP.NET执行任何自己的编译之前输入图片,因此缺少对System.Core引用的引用会导致系统失败(I我不确定为什么。

解决方案是手动编辑失败项目的csproj文件,并手动将对System.Core的引用添加到项目中。您无法从解决方案资源管理器中执行此操作,因为它不允许添加由MSBUILD自动添加的引用。

仍然不确定为什么它首先失败了,但至少它现在编译并再次通过测试。

答案 1 :(得分:0)

您是否在团队城市中将MSbuild切换到v4.0?我不认为您可以使用团队城市上的MSbuild 3.5来构建.Net 4.0的2010项目。