First of all, you can start by creating a conditional compilation symbol that allows you to include or exclude additional functions that are available only for the .NET4.0 platform.
Also, I think you will have to use MSBuild directly, instead of letting VS.NET build your project. Once I did something similar. In short, it comes down to the fact that you will need to create 2 build tasks in your MSbuild script. One that allows you to create your own project for .NET 3.5, and one that allows you to create your own project for .NET 4.0.
In each build task, you can define the target structure and conditional compilation symbol that you want to use.
The build tasks in your build script might like this:
<Target Name="buildall-v4"> <ItemGroup> <BuildConstant Include="DEBUG" Condition="'$(buildmode)'=='DEBUG'" /> <BuildConstant Include="RELEASE" Condition="'$(buildmode)'=='RELEASE'" /> <BuildConstant Include="NET_FRAMEWORK_4_0" /> </ItemGroup> <PropertyGroup> <BuildConstantsToUse>@(BuildConstant)</BuildConstantsToUse> </PropertyGroup> <MSBuild Projects="$(builddir)\Source\MyProject.sln" Properties="OutputPath=$(outputdir)\v4;Configuration=$(buildmode);DefineConstants=$(BuildConstantsToUse);TargetFrameworkVersion=v4.0" /> </Target> <Target Name="buildall-v3.5"> <ItemGroup> <BuildConstant Include="DEBUG" Condition="'$(buildmode)'=='DEBUG'" /> <BuildConstant Include="RELEASE" Condition="'$(buildmode)'=='RELEASE'" /> </ItemGroup> <PropertyGroup> <BuildConstantsToUse>@(BuildConstant)</BuildConstantsToUse> </PropertyGroup> <MSBuild Projects="$(builddir)\Source\MyProject.sln" Properties="OutputPath=$(outputdir)\v3.5\;Configuration=$(buildmode);DefineConstants=$(BuildConstantsToUse);TargetFrameworkVersion=v3.5" /> </Target>
Offcourse, when you want to build for two versions, you will have to run each msbuild command separately on the command line.
source share