【问题标题】:code depending on build-type?代码取决于构建类型?
【发布时间】:2010-02-01 09:22:43
【问题描述】:

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

例如:

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

【问题讨论】:

    标签: c# build


    【解决方案1】:
    #if DEBUG
      // Commands that should run in debug builds.
    #else
      // Commands that should run in release builds.
    #endif
    

    【讨论】:

    • 我必须在项目属性中检查“Define DEBUG contant”吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-25
    • 1970-01-01
    • 2017-04-30
    • 1970-01-01
    • 2022-10-20
    • 1970-01-01
    相关资源
    最近更新 更多