如何在xml格式的resx文件中添加条件编译?

dat*_*ayo 6 conditional-compilation visual-studio-2010 embedded-resource c#-4.0

NET项目,我需要根据某些编译符号在资源文件(这是一个xml文件)中添加内容.

类似以下内容:

<xml ....>
<myNodes>

#if SOMECONDITION
<node1>
...
</node1>

#else
<node2>
...
</node2>

#endif
</myNodes>
Run Code Online (Sandbox Code Playgroud)

这甚至可能吗?我知道这不符合XML规则.是否有类似的方法来使用条件编译并且还要遵守XML规则?

Muh*_*qib 0

我不能 100% 确定这可以解决您的问题,但您可以尝试条件构造。xml中没有这样的条件编译。

 <rule>
    <if>
         <condition var="''$(Configuration)'" operator="=;">Debug</condition>
            <!-- more conditions possible -->
        </conditions>
        <statements>
            <!-- put your tage here -->
            <node1> ... </node1>
        </statements>
    </if>
    <else>
        <node2>
        ...
        </node2>
    </else>
</rule>
Run Code Online (Sandbox Code Playgroud)