Im using NAnt and CCNet on our build server. Lately when i've been doing Local Deployment, i get build errors that seems to be connected to Linq, generics and delegates.
Here are the result:
[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
On my machine i can build with no problems (vs2010). Im using the latest NAnt 0.91b.
Update:
The project has target framework 3.5. Beneath is the code that generates the error (return section in first method):
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
};
}
When you use vs2010 you need to set it to target framework 4.0 in the nant script or you can directly call the correct version (4.0) of msbuild and pass in your solution file.
Our current build script does it like that:
<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>
Where the ${msbuild.path}
is <property name="msbuild.path" value="C:\Windows\Microsoft.NET\Framework\v4.0.30319" />