简体   繁体   中英

How to force Visual Studio to use .Net 2.0 compiler?

The build machine where I work still uses the .Net 2.0 compiler.

I've set up Visual Studio to target the .Net Framework 2.0, but when I use the keyword var , it's compiling (since the compiler automagically change the type). But it breaks on the build machine compiler.

Is there a way to setup Visual Studio to break on those things, or even force it to use the 2.0 compiler, so that I won't make the mistake to break the build by using "too new" functionalities?

If I remember correctly, each version of .Net was tied to a specific version of DevStudio and it isn't possible to change this. If you need to compile for .Net 2 then you need the VS2005 compiler. One way to solve this is to use makefiles rather than the IDE to build the application and specify explicitly which compiler is used for each file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM