如何在Visual Studio pre/post-build命令行中检测调试/发布?

Nan*_* HE 4 c# post-build-event visual-studio pre-build-event c#-2.0

如何从命令行预构建后构建窗口中检测调试释放模式?

我测试了下面的代码,它在代码文本窗口中工作.它可以转换为命令行代码吗?如果可以,怎么做,谢谢.

bool debugging = false;
#if DEBUG
    debugging = true;
    // do something like to move ../debug/bin/ to somewhere.
#else
    debugging = false;
    // do something like to move ../debug/bin/ to somewhere.
#endif

Console.WriteLine(debugging);
Run Code Online (Sandbox Code Playgroud)

slu*_*ter 7

您可以检查$(ConfigurationName)变量的值.

它与您在代码示例中使用的内容不同.#if DEBUG是条件编译指令,它取决于是否DEBUG已定义为符号.该ConfigurationName变量取决于什么构建配置已指定(这是独立的条件编译符号).


归档时间:

查看次数:

4231 次

最近记录:

14 年,6 月 前