Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2008 - Outputting a different file name for Debug/Release configurations

Tags:

When building a C# application with Visual Studio 2008, is it possible to set a different output filename per configuration?

e.g.  MyApp_Debug.exe MyApp_Release.exe 

I tried a post-build step to rename the file by appending the current configuration, but that seems a scrappy approach. Plus it meant that Visual Studio could no longer find the file when pressing F5 to start debugging.

like image 781
xyz Avatar asked Jul 07 '09 16:07

xyz


People also ask

How do I change debug config in Visual Studio?

In Solution Explorer, right-click the project and choose Properties. In the side pane, choose Build (or Compile in Visual Basic). In the Configuration list at the top, choose Debug or Release. Select the Advanced button (or the Advanced Compile Options button in Visual Basic).

What's the difference between debug and release?

By default, Debug includes debug information in the compiled files (allowing easy debugging) while Release usually has optimizations enabled. As far as conditional compilation goes, they each define different symbols that can be checked in your program, but they are language-specific macros.

What is the difference between debug and release in C#?

The biggest difference between these is that: In a debug build the complete symbolic debug information is emitted to help while debugging applications and also the code optimization is not taken into account. While in release build the symbolic debug info is not emitted and the code execution is optimized.


1 Answers

You can achieve this by editing your project file by hand. Locate the <AssemblyName> node and add a conditional attribute to it:

<AssemblyName Condition="'$(Configuration)'=='Debug'">MyApp_Debug.exe</AssemblyName> <AssemblyName Condition="'$(Configuration)'=='Release'">MyApp_Release.exe</AssemblyName> 

You'll have to duplicate it also to add another conditional attribute for the release version.

Whilst it is possible, it may cause problems. There is an AssemblyConfiguration attribute that can be applied to your assembly. In AssemblyInfo.cs, put:

#if DEBUG [assembly: AssemblyConfiguration("Debug")] #else [assembly: AssemblyConfiguration("Release")] #endif 

This will add a property to your compiled assembly that will tell you which build configuration your application was built using.

like image 168
adrianbanks Avatar answered Oct 03 '22 12:10

adrianbanks