Linq导致生成错误

| 我在构建服务器上使用NAnt和CCNet。最近,当我一直在进行本地部署时,出现了似乎与Linq,泛型和委托有关的构建错误。 结果如下:
[nant] C:\\Test\\buildfiles\\build.build
 Buildfile: ..........
 Target framework: Microsoft .NET Framework 3.5
 Target(s) specified: build

build:
   [csc] Compiling 192 files to \'C:\\TEST\\bin\'.
   [resgen] Read in 78 resources from \'C:\\Test\\Resources\'.
   [csc] c:\\Test\\src\\randomfile.cs<10,10>: error CS0411: The type arguments for method \'System.Linq.Enumerable.Select<TSource,TResult><System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,TResult>>\' cannot be inferred from the usage. Try specifying the type arguments explicitly
在我的机器上,我可以毫无问题地进行构建(vs2010)。我正在使用最新的NAnt 0.91b。 更新: 该项目具有目标框架3.5。 下面是生成错误的代码(第一种方法的return部分):
public static RoleTypeIdAndName[] TranslateRoleTypes(RoleType[] roleTypes)
{
    return roleTypes.Select(TranslateRoleType).ToArray();
}

public static RoleTypeIdAndName TranslateRoleType(RoleType roleType)
{
    return new RoleTypeIdAndName
            {
                Name = roleType.Name,
                RoleTypeId = roleType.RoleTypeId
            };
}
    
已邀请:
        使用vs2010时,需要在nant脚本中将其设置为目标框架4.0,或者可以直接调用正确的msbuild版本(4.0)并传入解决方案文件。 我们当前的构建脚本是这样做的:
<target name=\"msbuild\" depends=\"create.common.assembly.info\">
    <echo message=\"Compiling ${msbuild.workingpath}\\${solution.path}\"/>
    <echo message=\"Build base path ${msbuild.path}\"/>

    <exec program=\"msbuild.exe\" basedir=\"${msbuild.path}\" workingdir=\"${msbuild.workingpath}\">
      <arg value=\"/p:Configuration=${project.configuration}\" />
      <arg value=\"/v:q\" />
      <arg value=\"/p:trackfileaccess=false\" />
      <arg value=\"/t:Clean\"/>
      <arg value=\"${solution.path}\"/>
    </exec>

    <exec program=\"msbuild.exe\" basedir=\"${msbuild.path}\" workingdir=\"${msbuild.workingpath}\">
      <arg value=\"/p:Configuration=${project.configuration}\" />      
      <arg value=\"/v:q\" />
      <arg value=\"/p:trackfileaccess=false\" />
      <arg value=\"/t:Rebuild\"/>
      <arg value=\"${solution.path}\"/>
    </exec>
    <property name=\"msbuild.output.file\" value=\"${msbuild.workingpath}/msbuild-output.xml\"/>
    <move if=\"${file::exists(msbuild.output.file)}\" file=\"${msbuild.output.file}\" todir=\"${log.path}\" failonerror=\"false\" overwrite=\"true\" />
  </target>
${msbuild.path}
<property name=\"msbuild.path\" value=\"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\" />
    
        没有看到您的代码,我想这是此页面上提到的情况之一。     

要回复问题请先登录注册