Visual Studio:自定义项目变量 [英] Visual Studio: custom project variables

查看:61
本文介绍了Visual Studio:自定义项目变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio 提供了很多可以在 IDE 内部使用的 $ 变量,例如 $(SolutionDir).如何创建自己的变量,例如 $(MY_INCLUDES_DIR)(可以由项目用户设置以指向其标题)?甚至有可能吗?

Visual studio provides a lot of $ variables that can be used inside the IDE such as $(SolutionDir). How can one create their own variables such as $(MY_INCLUDES_DIR) (that can be set by users of a project to point to their headers)? Is it even possible?

推荐答案

我知道这适用于 VS 2010:

I know this works for VS 2010:

如果您有属性表,则通用属性"树下有一个名为用户宏"的部分.您可以创建自己的 $(MyNamedVariable) 宏,甚至可以根据其他 $(SomeExistingMacro) 定义它.如果您之前没有使用过属性表,请在视图菜单下查找属性管理器",它会允许您创建和编辑它们.

If you have property sheets, there is a section called "User Macros" under the "Common Properties" tree. You can create your own $(MyNamedVariable) macro, and even define it in terms of other $(SomeExistingMacro). If you have not played with property sheets before, look for the "Property Manager" under the view menu, and it will allow you to create and edit them.

任何继承属性表的项目配置都会看到你的宏,就像 VS 自己定义它一样,即它会显示在宏列表中.您项目的用户只需转到某个基本属性表,然后在一个地方编辑 MY_INCLUDES_DIR(以使用您的示例).

Any project configuration that inherits the property sheet will see your macro as if VS had defined it itself, ie it will show up in the list of macros. User of your project can just go to some base property sheet, and edit the MY_INCLUDES_DIR (to use your example) in a single place.

希望这会有所帮助.

(如何创建属性表?参见 http://msdn.microsoft.com/en-us/library/5k4a0033.aspx. View->Other Windows->Property Manger)

(How to create property sheets? See http://msdn.microsoft.com/en-us/library/5k4a0033.aspx. View->Other Windows->Property Manger)

这篇关于Visual Studio:自定义项目变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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