Only embed some resources in certain build configurations?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • P Chase

    Only embed some resources in certain build configurations?

    I have some resources in my C# Visual Studio 2005 project that are
    involved with self-test. Ideally, they shouldn't be in a released
    product.

    These resources are embedded by virtue of having their Build Action
    property set to Embedded Resource.

    Is there any way to add conditions to when they are embedded? For
    instance, can I create a build configuration under which they are not
    embedded?
  • Marc Gravell

    #2
    Re: Only embed some resources in certain build configurations?

    Yes; not via the IDE, but you can edit the csproj directly (right click,
    unload, edit) - add an attribute to the EmbeddedResourc e element:

    <EmbeddedResour ce Include="Foo.tx t"
    Condition="'$(C onfiguration)'= ='Debug'" />

    (or whichever configuration you want to include it in)

    Marc

    Comment

    • P Chase

      #3
      Re: Only embed some resources in certain build configurations?

      On 14 Apr, 10:56, Marc Gravell <marc.grav...@g mail.comwrote:
      Yes; not via the IDE, but you can edit the csproj directly (right click,
      unload, edit) - add an attribute to the EmbeddedResourc e element:
      >
      <EmbeddedResour ce Include="Foo.tx t"
      Condition="'$(C onfiguration)'= ='Debug'" />
      >
      (or whichever configuration you want to include it in)
      >
      Marc
      Thanks. That works fine. Is it likely that Visual Studio will
      overwrite my hand-edited addition in the future, or is it smart enough
      to persist it, once added?

      Comment

      • Marc Gravell

        #4
        Re: Only embed some resources in certain build configurations?

        I haven't seen any oddities... you might want to keep an eye on it when
        changing from 2005 to 2008, for example, but in general it seems to know
        enough to leave it alone...

        But if you see any problems...

        Marc

        Comment

        Working...