基于配置的条件内容 [英] Conditional Content Based Upon Configuration
问题描述
我已经尝试过多次使用与条件引用"类似的技术来处理条件内容.
I've tried several times to use a similar technique as "conditional references" for conditional content.
Visual Studio Project文件中的内容条目,例如"web.config",我不在发布网站时不希望包含.
Content entries in the Visual Studio Project file such as "web.config" I do not want included when I publish the website.
我已经尝试过一些类似的事情...
I've tried a few things like...
<Choose>
<When Condition="$(Configuration) != 'Release'">
<ItemGroup>
<Content Include="web.config">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
</ItemGroup>
</Otherwise>
</Choose>
但这不起作用.有任何想法吗?还是您以前遇到过并解决了这个问题?
But this doesn't work. Any ideas? Or have you encountered this before and solved it?
推荐答案
我相信您可以将条件添加到ItemGroup ...示例:
I believe you can just add the Condition to the ItemGroup... Example:
<ItemGroup Condition="'$(Configuration)' != 'Release'">
<Content Include="web.config">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
请注意条件中"$(Configuration)"周围的勾号.这些是非常必要的.
Note the ticks around '$(Configuration)' in the condition. Those are very necessary.
这篇关于基于配置的条件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!