2

I have c# application. The application includes resource file with images and icon. My target is to compile the same application but with different set of images/icons. Same images name, but different content.

Is there a way to include different resource file in compile time on condition?

folibis
  • 12,048
  • 6
  • 54
  • 97
  • Sounds like you should take a look a publish profiles – ste-fu Nov 17 '16 at 15:03
  • There are several ways you could achieve that. Pry-open the `.csproj` file and make up a new build constant (another besides `DEBUG` and `TRACE`) and conditionally include your resources based on the presence or absence of such constant's definition. That approach is not really flexible and scalable (no support from the IDE itself). You could also have two different projects and include common stuff as links or project references, that would be better I guess. Finally, you can have a single application with two different satellite assemblies: that's best I would say. – Leandro Nov 17 '16 at 15:04

1 Answers1

2

Maybe you are looking for Preprocessor Directives or Conditional Attribute.

Preprocessor directives

From this tutorial by Bipin Joshi:

C# preprocessor directives are commands that are meant for the C# compiler. Using preprocessor directives you instruct the C# compiler to alter the compilation process in some way. For example you may instruct the C# compiler that a particular block of code be excluded from the compilation process.

ConditionalAttribute

From MSDN

Indicates to compilers that a method call or attribute should be ignored unless a specified conditional compilation symbol is defined.

To compare these two see this post.

Community
  • 1
  • 1
WerWet
  • 323
  • 5
  • 14