如何确保 vsvars32.bat 已运行
我有一个使用 MSVC 2005 的构建过程。它仅在从 Visual Studio 命令提示符运行时才能正常工作,而不是从常规命令提示符运行,因为设置了其他变量。运行错误类型的提示然后收到晦涩的错误消息太容易了,所以我试图避免这种情况。我不想将常规命令提示符更改为始终调用 vsvars32.bat,因为我并不总是希望这样做,但我想添加一条消息以建议使用 Visual Studio 命令提示符。为此,我编写了一个 BAT 文件
if "%VSINSTALLDIR%" == "" echo 您想要 Visual Studio 命令提示符吗?
但是,这也会显示在 Visual Studio 命令提示符中,因为它在 vsvars32.bat 之前被调用。
有谁知道如何将一条消息添加到普通命令提示符而不是 Visual Studio 2005 命令提示符中?我怀疑 Visual Studio 命令提示符的设置方式是不可能的。
谢谢。
I have a build process using MSVC 2005. It only works correctly if run from a Visual Studio command prompt, not from a regular command prompt, because of the additional variables that get set. It's far too easy to run the wrong type of prompt and then get obscure error messages, so I'm trying to avoid this. I don't want to change my regular command prompt to always call vsvars32.bat, since I don't always want this, but I wanted to add a message to suggest using the Visual Studio Command Prompt. To do this, I wrote a BAT file
if "%VSINSTALLDIR%" == "" echo Did you want a Visual Studio Command Prompt?
However, this also shows up in the Visual Studio Command Prompt because it gets called before vsvars32.bat does.
Does any one have any idea how I could get a message added to a normal command prompt but not the Visual Studio 2005 Command Prompt? I suspect from how the Visual Studio Command Prompt is set up this isn't possible.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不在构建过程中执行
vsvars32.bat
?另一个选项是使用诸如 cmd.exe /k path-to-vs\vsvars.bat - IIRC 之类的东西显式生成 shell,/k
选项使 shell执行论证并保持开放。Why not execute
vsvars32.bat
from within your build process? The other option is to explicitly spawn a shell using something likecmd.exe /k path-to-vs\vsvars.bat
- IIRC, the/k
option makes the shell execute the argument and remain open.