在Visual Studio中使用构建配置一个项目的多个版本 [英] Create multiple versions of a project in Visual Studio using Build Configurations

查看:207
本文介绍了在Visual Studio中使用构建配置一个项目的多个版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我neeed创建使用的配置,就像我们做的的#define #如果我的项目的多个版本, #ENDIF

I neeed to create multiple versions of my project using configuration just like we do with #define, #if, #endif.

使用这些预处理器指令的一面是,我需要在几乎每一个来定义符号该项目的文件,但我想通过我的构建配置来处理这件事情。

The down side of using these preprocessor directives is that I need to define symbols in almost every file of the project but I want to handle this thing by my build configurations.

我甚至不知道,如果构建配置将帮助我做到这一点。

I am not even sure if Build Configurations will help me to do this.

我要的是如果我创建一个名为发展等名称为质量保证,我的代码看起来像一个配置:

What I want is if I create a configuration with name "Development" and other with name "QA", my code would look like:

if #Development or if $QA

请指导我实现这一点。

推荐答案

配置管理器这个原因存在。

Configuration Manager exist for this reason.


  • 转至配置管理器,并从预定义的调试配置创建一个新的配置
    复制

  • 名称配置发展,适用于所有项目

  • 转至每个项目的属性页需要选择作为当前配置的开发配置(应该已经是
    处于活动状态)

  • #如果发展
    条件编译并插入符号发展在构建标签

  • Go to the Configuration Manager and create a New Configuration copying from the predefined DEBUG configuration
  • Name the configuration DEVELOPMENT and apply to all projects
  • Select as Active Configuration the DEVELOPMENT configuration (should already be the active one)
  • Go to the properties page of each project requiring #if DEVELOPMENT conditional compile and insert the DEVELOPMENT symbol in first textbox of the BUILD tab

现在每个项目都可以使用#如果发展预处理指令

Now each of your projects can use the #if DEVELOPMENT preprocessor directive

如果你需要,这也为取消重复上面的步骤,但是从预定义的复制发布配置并给予不同的名称

If you need this also for RELEASE repeat the above steps but copy from predefined RELEASE configuration and give a different NAME

现在从配置有或没有定义的,可以直接从的标准工具栏目前的解决方案配置组合工具进行开发的符号切换Visual Studio中没有编辑每个项目。

Now switching from a configuration with or without the DEVELOPMENT symbol defined could be done directly from the Solution Configurations combo Tool present in the Standard Toolbar of Visual Studio without editing each project.

您还可以查看MSDN文章的如何创建和编辑配置

You can also view MSDN article How to: Create and Edit Configurations

这篇关于在Visual Studio中使用构建配置一个项目的多个版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆