Selective resource compiling in .NET?


How can I choose which resources to compile depending of the compile constants used? So, if VAR1=0 then I wouldn't add RESOURCE_A to my final assembly.

I searched around, but didn't find any info regarding this... I guess I'm using the wrong keywords, since I doubt nobody else had this problem/doubt ever before.

Also, I use both VS2005 and 2008 at my job, mainly VB, although I haven't got any problem using C# either.


You could accomplish this using the MSBuild <Choose> element:

    <When Condition=" '$(Configuration)'=='Debug' ">
            <EmbeddedResource Include="debug_resource.txt" />
    <When Condition=" '$(Configuration)'=='retail' ">
            <EmbeddedResource Include="retail_resource.txt" />

... of course, you could use something other than the $(Configuration) variable. You can check existence of a file/folder, use the output of another task, or use a different variable altogether.

By : Mark

Compile constants only affect code. You could add both resources to the assembly, and retrieve the appropriate one depending on the compile constant.

There are of course other ways to achieve this - e.g. copying the appropriate resource in a pre-build event based on some criterion you define.

By : Joe

See if this helps :

Set a flag inside the exception handler and check it before working on the s.

flagBreak = false;
while True :

    if flagBreak : break

    if s :
        print s
    try :
        s =
    except StopIteration :
        flagBreak = true

print "done"
By : Nrj

This video can help you solving your question :)
By: admin