代码取决于构建类型?

时间:2010-02-01 09:22:44

标签: c# build

我正在使用Visual c#Express 2008.我想在“Release”版本中执行一个特殊命令 - 在我创建和运行Debug版本时不应执行此命令。是否可以根据我的构建类型(Debug或.Release)实现代码?

例如:

if(??buildtype?? == "Release")
{
 //... special command ...
 MessageBox.Show("RELEASE version");
}
else
{
//... normal command ...
MessageBox.Show("debug release");
}

1 个答案:

答案 0 :(得分:12)

#if DEBUG
  // Commands that should run in debug builds.
#else
  // Commands that should run in release builds.
#endif