2010-02-01 36 views
3

我正在使用Visual C#Express 2008.我想要在“发布”版本中执行特殊命令 - 在创建和运行调试版本时不应该执行此命令。是否有可能根据我的构建类型(Debug或.Release)实现代码?代码取决于构建类型?

例如:

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

回答

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

我必须检查的项目性的判定 “定义DEBUG含量的不同”? – Tobias 2010-02-01 09:38:11