We can switch to different .NET Framework target in Visual Studio after 2008.
I have a project, and I want to build 2 different target Frameworks assembly of it. If my target Framework is 2.0, I want it to build some code, and when I switch to another target Framework, I want it to build another code fragment to use some new functions.
now I have to manually comment and uncomment code everywhere, I wonder if I can use some precompile symbols to dynamically do this to me. Like:
#if Framework3
<do something>
#else
<do something else>
#endif
Can I?
Yes, we do this in MiscUtil. I'm not sure you can do it directly in Visual Studio, as the target framework choice is in a property page which ignores the current configuration. However, you can edit the project file directly, to get the right target framework for the right configuration. In particular, you'll want to make sure you don't have .NET 3.5 references when targeting .NET 2.0. Have a look at our main project file (MiscUtil.csproj) for more details.
The preprocessor symbol part is easy - once you've got a build configuration for .NET 2.0 you can add preprocessor symbols directly in Visual Studio.