在MSBuild的,你可以指定项目组的条件。然后,您可以将这些条件绑定到目标设备。
例子:
<!-- Declare the condition property at the beggining of the build file -->
<PropertyGroup Condition="$(Platform) == 'IE7'">
<UseNewLibrary>true</UseNewLibrary>
</PropertyGroup>
<PropertyGroup Condition="$(Platform) == 'IE6'">
<UseNewLibrary>false</UseNewLibrary>
</PropertyGroup>
<!-- Then those the property to select the right file -->
<ItemGroup Condition="$(UseNewLibrary)==true">
<Compile Include="Class1.cs"/>
<Compile Include="Class2.cs"/>
<Compile Include="Class3.cs"/>
<Compile Include="Class4.cs"/>
</ItemGroup>
<ItemGroup Condition="$(UseNewLibrary)==false">
<Compile Include="Class1Old.cs"/>
<Compile Include="Class2Old.cs"/>
<Compile Include="Class3Old.cs"/>
<Compile Include="Class4Old.cs"/>
</ItemGroup>
<!-- And now references -->
<ItemGroup Condition="$(UseNewLibrary)==true">
<Reference Include="MyAssembly, Version=1.1.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</ItemGroup>
<ItemGroup Condition="$(UseNewLibrary)==false">
<Reference Include="MyAssembly, Version=1.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</ItemGroup>
注意,所有文件都将出现在IDE,但是在编译的时候一切都应该正确对齐。
然后,您需要做的就是在配置管理中创建您的平台(IE6和IE7)。
您也可以直接使用平台属性,而不是创建中间属性。
由于我的文件m挂钩到IE提供的API中,这个API在不同版本中有所不同,因此存在各种各样的问题渲染API,以及具有不同的互操作程序集等......编译两个版本稍微不同的代码更简单。 – Rory 2009-02-10 19:03:07
噢,太糟糕了:(看起来Coincoin的答案会做你想做的事情) – 2009-02-10 19:10:57