views:

148

answers:

2

I have a project that i want to compile for 2.0 and 3.5 is there any way to do this in vs 2008?

+2  A: 

Code compiled for 2.0 will run under 3.5. If you're not using any of the new features of 3.5 (and you're not, otherwise you couldn't compile to 2.0) then there's no pressing reason to compile against it.

tylerl
Well the reson for this is, .net 3.5 code can run from a network drive 2.0 can't or atleast not without configuration. we have a lib where we store stuff that we use often, and we use bothe 3.5 and 2.0 so i would want to build 2 versions of the Lib one 3.5 and one 2.0
Petoj
It's perfectly possible to have methods which can be streamlined in .NET 3.5, or features of a library which are only feasible in .NET 3.5. See my answer for an example of this.
Jon Skeet
@Petoj: That difference is nothing to do with the assemblies, and everything to do with the configuration of the local .NET runtime and security. .NET 3.5 has a different default, a .NET 2 install can be changed... or better upgrade it (3.5 == 2.0+fixes+extra-libraries).
Richard
+3  A: 

Yes. You can use conditional references and things like that. Marc Gravell set this up for the MiscUtil project - the best way to find out how to do it is probably to download the source and have a look. We use C# 3.0 features, so it's only compatible with Visual Studio 2008, but we have build configurations for .NET 2.0 and .NET 3.5, so it's just a case of changing the current build to check that things still work. (The release scripts build both versions, of course.)

Jon Skeet