更新时间:2023-02-27 10:41:54
你应该能够通过直接编辑项目文件来使用条件结构来做到这一点(VS IDE 不会为你做到这一点).
You should be able to do this with conditional constructs by editing the project file directly (VS IDE won't do this for you).
例如,您可以使用选择"元素执行以下操作:
For example, you might do something like this using the "Choose" element:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<PropertyGroup>
<!-- ... -->
</PropertyGroup>
<Choose>
<When Condition=" '$(Configuration)'=='Debug' ">
<ItemGroup>
<ProjectReference Include="..stuffMyStuff.csproj">
<Project>{4c7bbe47-8d84-45d4-95f0-f640ba59563c}</Project>
<Name>MyStuff</Name>
</ProjectReference>
</ItemGroup>
</When>
<When Condition=" '$(Configuration)'=='Retail' ">
<ItemGroup>
<Reference Include="MyStuff.dll" />
</ItemGroup>
</When>
</Choose>
<!-- Rest of Project -->
</Project>
MSDN 有有关使用条件结构的更多信息.