c# - the type or namespace name 'linq' could not be found in 'system' -
i'm trying understand process of bulding c# project using microsoft build engine (also known msbuild) , face problem. problem simple, think don`t understand something.
i wrote simple program consist 2 .cs files. first file "mathop.cs". in file define 2 functions: add(double num1, double num2) , multiply(doble, double); second file "program.cs." here define 2 variable passed add function placed in mathop file , getting rezult; programm correct.
then wrote simple msbuild file define tasks , targets building. , when launch in visual studio command prompt getting erorr cs0234: type or namespace name linq not found in system namespace. interesting referenced system.dll , etc. in msbuild file. , if comment using directives in program.cs file error disappear.
<project defaulttargets="compile" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" > <propertygroup> <assemblyinfo>build</assemblyinfo> <builtdir>build\</builtdir> </propertygroup> <itemgroup> <csfile include="msbuildtest\program.cs"/> <csfile include="msbuildtest\properties\assemblyinfo.cs"/> <csfile include="msbuildtest\mathop.cs"/> <reference include="system.dll"/> <reference include="system.data.dll"/> <reference include="system.drawing.dll"/> <reference include="system.windows.forms.dll"/> <reference include="system.xml.dll"/> </itemgroup> <target name="prebuild"> <exec command="if not exist $(builtdir) md $(builtdir)"/> </target> <target name="compile" dependsontargets="prebuild"> <csc sources="@(csfile)" references="@(reference)" outputassembly="$(builtdir)$(msbuildprojectname).exe" targettype="exe"/> </target> <target name="clean" > <exec command="del $(builtdir)$(assemblyinfo).exe"/> </target> <target name="rebuild" dependsontargets="clean;compile"/>
in current state msbuild use csc .net 2.0, know nothing linq.
the easiest way fix issue specify 4.0 version in msbuild project forcing msbuild use correct csc version:
<project toolsversion="4.0" defaulttargets="compile" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
Comments
Post a Comment