Conditional Content Based Upon Configuration

☆樱花仙子☆ 提交于 2019-11-30 08:35:15

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> 

Note the ticks around '$(Configuration)' in the condition. Those are very necessary.

I would like to extend the answer provided by Nick Nieslanik with some details just so others aren't stumped in the same way I was.

The solution works during build/publish, but Visual Studio 2010's interface may not reflect the changes made. Whether this is a defect or not, I am not sure, but it did confuse me and it may confuse others.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!