0

I have 2 build-specific configuration code blocks. The first one should be applied when the app is launched locally and the second one when I publish the site to the web. Now I comment/uncomment one of them when I need to publish. So I wonder is there any way to do something like this:

#if PUBLISH
    anyConfig = "publish_config";
#else
    anyConfig = "debug_config";
#endif

Thanks in advance!

4

1 回答 1

2

选择 RELEASE 配置,然后转到项目的属性页面,并将 Build 页面中的 PUBLISH 定义添加到 Conditional Symbol 文本框中。

当您准备好部署您的应用程序时,再次切换到 RELEASE 配置并构建您的应用程序。

您还可以创建自定义配置。

  • 转到构建菜单并选择配置管理器
  • 在当前配置组合框中选择新建
  • 为您的配置命名并选择基本配置(如果在调试会话期间使用此新配置,则为调试)
  • 请务必检查 -> 每个项目的新配置。

现在您可以像为 DEBUG 或 RELEASE 一样选择此新配置,并将您的唯一符号添加到此配置中。

(我将此方法用于 WinForm 应用程序,其中某些功能仅适用于 RELEASE_PRO 配置)

于 2012-07-14T20:14:11.117 回答