I'm trying to compile an #ifdef'd codebase to two different target frameworks, namely 3.5 and 4.0.
I attempted to modify the .proj files in the solution to no avail.
It seems MSBuild / VS2012 isn't picking up the solution configuration change via UI.
This is a fragment of one of the .proj files:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Binaries\</OutputPath>
<DefineConstants>TRACE;NET35</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 40|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\Binaries\</OutputPath>
<DefineConstants>TRACE;DEBUG;NET40</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
When I switch to "Debug 40" from "Release" the target framework does not change in the project properties (thus breaking the compilation because of other conditionally referenced assemblies).
I'm also having problems conditionally referencing different assemblies, as if, again, the solution configuration isn't picked up by VS/MSBuild (some don't even show up in the references).
Edit: I'm excluding Microsoft.CSharp from the v3.5 build with the following line:
<Reference Include="Microsoft.CSharp" Condition=" '$(Configuration)' == 'Debug 40'" />
So far it seems it's just the TargetFrameworkVersion property that is ignored.