Visual Studio 2010 - 如何使用系统环境变量?

发布于 2024-09-27 08:06:02 字数 819 浏览 0 评论 0原文

我真的很感谢您在一个非常令人沮丧的问题上提供一些帮助或想法。根据我的经验,似乎任何时候我需要组织或更新我的解决方案/项目时,我都会意识到该程序实际上有多么错误和糟糕。我总是最终不得不寻找破解方法或因失败而遭遇令人讨厌的考验,这迫使我在这个过程中至少从头开始一次。

无论如何,我的问题是我从 2005 年到 2008 年一直在升级项目,现在是时候让 2010 年启动并运行了。对于我的旧项目,我一度决定使用系统环境变量设置为我的输出目录。

例如:

My Machine:
System->Advanced Settings->Environment Variables 3DSMAX_DEV_ROOT_32 = F:/Temp/Rampage/
My Project->General:
Output Directory = $(3DSMAX_DEV_ROOT_32)
My Project->Linker->General:
Output File = $(OutDir)MyPlugin.dll

这始终适用于 Visual Studio 2005 和 2008,而且我仍然严重依赖它。然而,对于2010年来说,这是行不通的。如果我是唯一处理过这个问题的人,但我没有看到其他人遇到过这个问题,我会感到惊讶。其他人提到了项目环境变量,但我在系统变量上没有看到任何内容。不管怎样,如果你有任何想法如何让它们发挥作用,或者知道为什么他们现在似乎完全忽视它们,我很想听听。更糟糕的是,我知道前导数字通常是禁忌,但我的 EV 有它们,而 VS 的 EV 不允许有它们。我知道有一种方法可以解决这个问题,但我在一个开发团队中,做出这个改变对每个人来说都是一个巨大的痛苦。

感谢您抽出时间阅读。

埃里克

I'd really appreciate some help or ideas on a very frustrating issue. In my experience it seems that any time I need to organize or update my solutions/projects, I realize how buggy and poor the program actually is. I always end up having to find a hack or run into a nasty trial by failure that forces me start from scratch at least once during the process.

Anyways, my issue is that I've been upgrading projects from 2005 to 2008 and the time has come to get 2010 up and running. For my older projects, I decided at one point to use System Environment Variables to set as my output directory.

For Example:

My Machine:
System->Advanced Settings->Environment Variables 3DSMAX_DEV_ROOT_32 = F:/Temp/Rampage/
My Project->General:
Output Directory = $(3DSMAX_DEV_ROOT_32)
My Project->Linker->General:
Output File = $(OutDir)MyPlugin.dll

This always worked for Visual Studio 2005 and 2008 and I still heavily depend on it. However, for 2010, it just won't work. I'd be surprised if I'm the only one who has dealt with this but I haven't seen anyone else run into it. Others have mentioned Project Environment Variables but I haven't seen anything on the system ones. Anyways, if you have any ideas how to make them work or know why they now seem to completely disregard them, I'd love to hear about it. To make matters worse, I know leading digits are usually a no-no, but my EV's have them and VS's EV's are not allowed to have them. I know of a way I can get around it but I'm on a team of developers and making this change would be a huge pain for everyone.

Thanks for taking the time to read.

Erik

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

对岸观火 2024-10-04 08:06:02

PATH 是一个非常特殊的环境变量 - 您不应该使用它来指向 VS 输出的临时目录。

请注意,默认情况下,VS 不会使用系统环境中的以下环境变量,而是用自己的环境变量覆盖它们:

  • PATH
  • INCLUDE
  • LIBPATH
  • LIB

如果您确实希望 VS 使用系统变量来执行这些操作,则需要使用 /useenv 选项启动 Visual Studio:

devenv /useenv

但您仍然应该使用 PATH 之外的另一个变量 - 它确实非常特别。 (我有点惊讶的是,设置 System->Advanced Settings->Environment Variables Path = C:/Temp/ 不会导致您出现各种其他问题)。

PATH is a pretty special environment variable - you shouldn't be using it to point to a temp directory for VS output.

Note that by default, VS does not use the following environment variables from your system env, instead overriding them with it's own:

  • PATH
  • INCLUDE
  • LIBPATH
  • LIB

If you do want VS to use your system variables for these, you need to start Visual Studio with the /useenv option:

devenv /useenv

But you still should use another variable than PATH - it's really pretty special. (I'm kind of surprised that setting System->Advanced Settings->Environment Variables Path = C:/Temp/ doesn't cause you all sorts of other problems).

农村范ル 2024-10-04 08:06:02

好的,我知道这是一个迟到的答案,但我遇到了同样的问题并在这里结束,以便其他人可能会发现该解决方案有用。

该问题特定于变量名称:3DSMAX_DEV_ROOT_32

Visual Studio 2010 不会扩展以图窗开头的环境变量。
Visual Studio 2008 中的情况并非如此。

重命名或添加具有相同值的变量 THREEDSMAX_DEV_ROOT_32 ,该变量在项目属性中使用时将正确扩展。

Ok, I know it is kind of an late answer, but I had the same problem and ended here so others might find the solution useful.

The problem is specific to the name of the variable: 3DSMAX_DEV_ROOT_32

Visual Studio 2010 does not expand environment variables that start with a figure.
It was not the case in Visual Studio 2008.

Rename or add a variable THREEDSMAX_DEV_ROOT_32 with the same value and this variable will be correctly expanded when used in the property of the projects.

我是男神闪亮亮 2024-10-04 08:06:02

这也发生在我身上,这是在全新安装 Visual Studio 2010 或任何涉及的库之后发生的。

当然,首先检查环境变量是否设置(并且正确)。当我从 Visual Studio 2005 转移到 2010 时,我还从 Windows XP 转移到 Windows 7,然后一些程序安装在“Program Files (x86)”文件夹中,而不是没有“(x86)”的文件夹中。也请注意这一点!

当您右键单击您知道应该驻留在环境变量设置的路径之一的包含文件并按“打开文件”时,Visual Studio 2010 应该为您提供它所查找的包含目录的列表。未读,这部分是空的,可能显示一些简单的内容,例如“/include”而不是“C:/Program Files/YourProgram/include”。

我的解决方案相当简单,因为重新启动计算机后它就起作用了......只需尝试看看这是否也适合您。我认为这与环境变量的激活有关,它们是在重新启动时全局设置的。因此,如果您更改了一项,则需要重新启动才能使更改生效。

This happened to me as well, which happened after a fresh install of Visual Studio 2010 or any of the libraries involved.

Of course, first check if the environment variables are set (and are correct). When I transferred from Visual Studio 2005 to 2010 I also transferred from Windows XP to Windows 7, and some programs are then installed in the 'Program Files (x86)' folder instead of the one without '(x86)'. Take a note of that as well!

When you right click on an include file which you know should reside in one of the paths set by environment variables and press 'open file', Visual Studio 2010 should give you a list of include directories where it looked in. When the environment variables are not read, this part is empty and shows maybe something simple like '/include' instead of 'C:/Program Files/YourProgram/include'.

My solution was rather simple, because after a restart of the computer it worked... Just try and see if this does it for you too. I think it has to do with the activation of environment variables, they are globally set on a reboot. So also if you change one, you need to reboot to make the change effective.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文