locked
Embed resource conditionally at compile-time? RRS feed

  • Question

  • I have a project that in RELEASE mode, with all resources, weighs in at a modest 47MB. The problem is that I have to deploy to a device over a slow network and the 47MB is kinda painful. There are a lot of rarely used language translations, images, etc that are embedded into the final application that could be removed from a DEBUG version and bring the total down to under 10MB.

    Is there any way to conditionally exclude certain resources at compile-time (specifically if the build is DEBUG, but include if set to RELEASE)?

    Using Visual Studio 2005 and Visual Studio 2003.NET.

    Thanks!
    Alain

    Wednesday, October 3, 2012 10:38 AM

Answers

  • Hi Alain,

    You can modify the .csproj files to have a resources (or the ItemGroup for resources) include a condition for the buildtype. this way the resources are only compiled into the application when you want them to.

    Sample:

    <EmbeddedResource Condition=" '$(Configuration)|$(Platform)' == 'Release' "

    A different approach would be to move your resources to a separate assembly and 1. only update the resources assembly when needed, or 2. have a small resources assembly in place for debug builds.

    Hope this helps 


    Please mark the best replies as answers - Twitter: @rickvdbosch - Blog: http://bloggingabout.net/blogs/rick


    Wednesday, October 3, 2012 10:47 AM

All replies

  • Hi Alain,

    You can modify the .csproj files to have a resources (or the ItemGroup for resources) include a condition for the buildtype. this way the resources are only compiled into the application when you want them to.

    Sample:

    <EmbeddedResource Condition=" '$(Configuration)|$(Platform)' == 'Release' "

    A different approach would be to move your resources to a separate assembly and 1. only update the resources assembly when needed, or 2. have a small resources assembly in place for debug builds.

    Hope this helps 


    Please mark the best replies as answers - Twitter: @rickvdbosch - Blog: http://bloggingabout.net/blogs/rick


    Wednesday, October 3, 2012 10:47 AM
  • Hi Rick,

    Thanks! I've manually modified the .csproj file as follows:
    <EmbeddedResource Include="Resources\Help\Vietnamese\logon_settings_vi.txt" />

    gets changed to:
    <EmbeddedResource Condition=" '$(Configuration)' == 'Release' " Include="Resources\Help\Vietnamese\logon_settings_vi.txt" />

    as you suggested. With the hundreds of help files included in the full release build, I've dropped the size from 47MB to 12MB! I'm sure I'll be able to knock off a few MBs by identifying some other resources, but thats already a huge help.

    Thanks very much!
    Alain

    <Rick van den Bosch> wrote in message news:e986a641-6bee-4edc-8231-ab5a4b3edda2@communitybridge.codeplex.com...

    Hi Alain,

    You can modify the .csproj files to have a resources (or the ItemGroup for resources) include a condition for the buildtype. this way the resources are only compiled into the application when you want them to.
    Sample:

    <EmbeddedResource Condition=" '$(Configuration)|$(Platform)' == 'Release'
    "

    A different approach would be to move your resources to a separate assembly and 1. only update the resources assembly when needed, or 2. have a small resources assembly in place for debug builds.

    Hope this helps


    Please mark the best replies as answers - Twitter: @rickvdbosch - Blog: http://bloggingabout.net/blogs/rick

    Wednesday, October 3, 2012 11:24 AM