Using Visual Studio Command Prompt Tools Everywhere

空扰寡人 提交于 2020-01-24 12:17:26

问题


How can I use the tools included in the VS command prompt (Programs | MS Visual Studio 2008 | Visual Studio Tools | Visual Studio 2008 Command Prompt) from any command prompt (ie without calling vcvarsall.bat) or program?


回答1:


The easiest way to do this is to add the PATH, INCLUDE, LIB and LIBPATH environment variables that are listed in the vsvarsXX.bat file for VS2005 on a 32 bit Intel box.

Here's the sample for vsvars32.bat:

@SET VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8
@SET VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8\VC
@SET FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework
@SET FrameworkVersion=v2.0.50727
@SET FrameworkSDKDir=C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0
@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR
@if "%VCINSTALLDIR%"=="" goto error_no_VCINSTALLDIR

@echo Setting environment for using Microsoft Visual Studio 2005 x86 tools.

@rem
@rem Root of Visual Studio IDE installed files.
@rem
@set DevEnvDir=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE

@set PATH=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\BIN;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\bin;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\bin;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\VCPackages;%PATH%
@set INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\include;%INCLUDE%
@set LIB=C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib;%LIB%
@set LIBPATH=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB

@goto end

:error_no_VSINSTALLDIR
@echo ERROR: VSINSTALLDIR variable is not set. 
@goto end

:error_no_VCINSTALLDIR
@echo ERROR: VCINSTALLDIR variable is not set. 
@goto end

:end

Pick and fill in the values from there.




回答2:


Perhaps add to your path var the locations of bin folders for the tools provided by visual studio




回答3:


To get it to work from a program, the easiest route is probably to set all the environment variables permanently for the user.

To use it from a command prompt... I just use the Command Prompt Tools shortcut as my normal command prompt shortcut, so I've always got them anyway. The good thing about this approach is that you can have different shortcuts for different versions - so I have a VS2008 shortcut and a VS2010 shortcut.




回答4:


You might be interested in adding a "Visual Studio Command Prompt Here" context menu option in Windows Explorer. Scott Hanselman has a link to an .inf file you can run to make the registry changes for this



来源:https://stackoverflow.com/questions/1679560/using-visual-studio-command-prompt-tools-everywhere

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!