Skip to content

Instantly share code, notes, and snippets.

@nbxx
Created September 26, 2016 22:58
Show Gist options
  • Save nbxx/164ee9f80ff7c3a2f6c23370a4016bb0 to your computer and use it in GitHub Desktop.
Save nbxx/164ee9f80ff7c3a2f6c23370a4016bb0 to your computer and use it in GitHub Desktop.
using System;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
// Want to detect which build is used
Console.WriteLine(BuildConfiguration.IsDebug ? "Debug" : "Release");
}
public static class BuildConfiguration
{
/// <summary>
/// Gets a value indicating whether the assembly was built in debug mode.
/// </summary>
public static bool IsDebug
{
get
{
bool isDebug = true;
#if !DEBUG
isDebug = false;
#endif
return isDebug;
}
}
/// <summary>
/// Gets a value indicating whether the assembly was built in release mode.
/// </summary>
public static bool IsRelease
{
get
{
return !IsDebug;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment