我试图编译#ifdef'd代码库到两个不同的目标框架,即3.5和4.0。
I'm trying to compile an #ifdef'd codebase to two different target frameworks, namely 3.5 and 4.0.
我试图修改.proj文件该解决方案也没有用。
I attempted to modify the .proj files in the solution to no avail.
看来的MSBuild / VS2012是不是捡了通过用户界面解决方案配置的变化。
It seems MSBuild / VS2012 isn't picking up the solution configuration change via UI.
这是.proj文件中的一个片段:
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>当我切换到调试40,从放的目标框架并不在项目变更性能(从而打破,因为其他条件引用的程序集的编译)。
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).
我也有参考条件不同的组件,问题仿佛再次,解决方案配置ISN :T拾起VS /的MSBuild(有的甚至在参考文献中显示)
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).
编辑:我从V3.5版本不包括Microsoft.CSharp使用以下行:
I'm excluding Microsoft.CSharp from the v3.5 build with the following line:
<Reference Include="Microsoft.CSharp" Condition=" '$(Configuration)' == 'Debug 40'" />
到目前为止,似乎它只是被忽略TargetFrameworkVersion属性。
So far it seems it's just the TargetFrameworkVersion property that is ignored.
推荐答案原来,问题是双重的:
- ReSharper的(第7版)通过显示在不同的文件编译错误,使其难以实现真正有条件引用编译的代码使事情变得更难。我认为,第7版不支持手动项目文件的变化,所以一个头高达RS7用户。
- 编译时实际使用正确的框架VS2012不改变UI中的目标框架(尽管,为的MSBuild的详细输出看到)。
我最终设法让代码库编译有点耐心。 按@ granataCoder的建议,这也是更好地保持不同的输出路径(可能很容易像条件编译正交问题时忽略)。
I eventually managed to get the codebase to compile with a bit of patience. As per @granataCoder's suggestion, it's also better to keep different output paths (might be easy to overlook when dealing with orthogonal issues like conditional compilation).
更多推荐
有条件改变目标框架版本
发布评论