Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change name of exe depending on conditional compilation symbol

Can you tell Visual Studio to output a different name of an exe file depending on if a specific conditional compilation symbol is set?

like image 532
Patrick Avatar asked May 18 '10 08:05

Patrick


People also ask

How do you use conditional compilation symbols in C#?

Right click the project (The Class Library is a project) and click Properties to open the properties window. Then click the Build tab, input symbols in the “Conditional compilation symbols:” textbox. Use comma to separate each symbol (e.g. “MySymbol1,MySymbol2”). Then use them in this way.

What is conditional compilation in VB net?

Conditional compilation is the ability to specify that a certain block of code will be compiled into the application only under certain conditions. Conditional compilation uses precompiler directives to affect which lines are included in the compilation process.


1 Answers

If you load the .csproj file into a text editor, you can control the AssemblyName property:

<AssemblyName Condition="'$(Configuration)' == 'Debug'">WindowsFormsApplication9.Debug</AssemblyName>
<AssemblyName Condition="'$(Configuration)' != 'Debug'">WindowsFormsApplication9</AssemblyName>

Note though that this does not only change the file name, but the assembly name, which might mean trouble if you have other code referencing the assembly.

I never did this myself, so I can't really say how good or bad the idea is.

like image 74
Fredrik Mörk Avatar answered Oct 01 '22 03:10

Fredrik Mörk