我有一个项目,目前使用 VS 2010(可能使用 MSBUILD v4.0)在我的开发机器上愉快地编译,但它在 Team City 的 MSBUILD v3.5 下失败(在基于 Win 2003 服务器 w/.NET 2 的 VM 上运行, 3.5 和 4 安装)。这个项目新升级到 2010,现在在 CI 构建上失败了。我已经用谷歌搜索了这个并尝试了所有明显的东西(加上一些没有意义的东西)并且没有任何影响结果。
该项目失败并出现一系列错误,如下所示:
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 应用程序,它在其 configuration/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