Env vars for Visual Studio command prompt - visual-studio

I'm doing an RDP into a machine that has just the CLR installed, and doesn't have Visual Studio on it. Can I somehow load all the Visual Studio-specific environment variables on to the regular command prompt and convert it into the VS command prompt so that I'm able to build my projects via command line?
I looked at the vcvarsall.bat file. That calls the appropriate processor-specific batch file. Couldn't get any inputs from there.

Short of installing all VS, or tracing thru all the various batch files to find out what's getting set, you may be able to simply capture the env vars that are set.
Open up a VS command prompt, and run set > vars.bat
Then open up vars.bat, and put a set command in front of each line.
Not sure how much this will help, since you're going to be missing all the utilities that come with Visual Studio, but it does answer your question.

I don't recommend trying to copy only what you need. You'll need other header files, libraries, dlls, etc... You can instead install VS express edition.
If you are trying to debug a problem you can use remote debugging in Visual Studio or use WinDbg on the computer.

Related

How to add batch file in windows environment variable

I am following the installation guide for openvino on Windows. After a successful installation, we need to run setupvars.bat file in order to initialize the openvino environment. We can also add it permanently in environment variable so that it is initialized automatically. But the instructions are not given on how to add it.
I wanted to know if its possible to add the setupvars.bat so the it runs automatically. Also I need to run the visual studio from the same environment.
I always do this step manually which takes a lot time. I first open a cmd, navigate to the desired folder and then run setupvars.bat. After that from the same cmd, I navigate to the visual studio installed directory and then start the visual studio from the cmd so that visual studio is launched under same openvino environment. Is is possible to automate all this task. Thanks
Solution 1: You can set the environment variables for the visual studio as mentioned here - How do I set specific environment variables when debugging in Visual Studio?
Solution 2: Write one more batch file which will 1st call setupvars.bat & then open the visual studio. Then you can run the new bat file.
Solution 3: You can create a cmd shortcut like this - Run a Command Prompt command from Desktop Shortcut
In this, you can 1st call setupvars.bat and then cmd to open Visual Studio. Once you click the new shortcut both the things should happen automatically. You can even add this step along with the installer.

Obtain visual studio generated build command

I want to create a batch file for building releases of a multi-solution software. What I am curious about how may I obtain the exact MSBuild command that Visual Studio executes when I click on "Rebuild Solution"?
It is equivalent to
MsBuild /t:Rebuild /p:Configuration=<config>;Platform=<platform>
although VS actually generates a temporary msbuild file from the solution and then builds that. You get the file by setting an MSBuildEmitSolution environment variable:
open a VS command window
enter set MSBuildEmitSolution=1
enter devenv to open a VS instance within that command window so it uses the MSBuildEmitSolution environment variable
open and build your solution

How to execute VS2013 MSBuild from an EXISTING command prompt

I would like to "MSBuild" (VS2013) my application as part of a bigger ".cmd" script. I cannot let visual studio build a shell and issue commands into that shell (please don't ask why; if that were negotiable I wouldn't have to ask this question in the first place)
I have the shell, its path, and its environment variables prepared for everything else (except Visual Studio 2013 and MSBuild). What can I do or invoke, so that the next command then can be "MSBuild..."
I have spent hours searching in vain but all I have found looks to me like it requires building a new shell, applying a mouse click, or loosing the standard input.
Thanks
Run vsvars32.bat. It is in the Common7\Tools folder of your Visual Studio installation. In the case of VS 2013, this folder is available in the environment variable, VS120COMNTOOLS. It is similar for other versions of VS. Your script will be something like:
call "%VS120COMNTOOLS%vsvars32.bat"
msbuild mysolution.sln /t:Build

MS C++ 2010 and mspdb100.dll

Microsoft's C++ compiler and linker seem to have an odd relationship with mspdb100.dll. When run from the IDE, of course, the compiler and linker work fine. When running either one from the command line, I get an error.
No problem, I located the DLL and copied it to the directory. Now the compiler works fine, but the linker dies.
I could solve the problem by adding "%VS10%\Common7\IDE" to my PATH, but for various reasons (performance, system purity, OCD, etc), I don't want to do that. Why is this setup so touchy, and is there anything else I can do to solve it?
try running path\to\VC\bin\vcvars32.bat from within your current shell first. This should ensure your command-line setup will match the IDE-setup.
This is not a permanent fix -- you need to do it every time you launch a new shell.
You could probably also find some way to add everything that's in that .bat permanently to the environment variables, but.... like you asked, why the heck doesn't the MS install do that already?
Add Microsoft Visual Studio 10.0\Common7\IDE to your path, and this issue will not exist any more. You will be able to build without running this silly batch file every time.
I noticed when I installed Microsoft Visual Studio 2010 Express that under the "Microsoft Visual Studio 2010 Express" folder in the Start Menu, there is a link to "Visual Studio Command Prompt (2010)", which sets up all the necessary environment variables when opened. That way you shouldn't have to edit you PATH variable.
This shortcut runs the following:
%comspec% /k ""C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
If it's not convenient to use the shortcut, perhaps you could learn something of use from investigating what this .bat file does?
I met same error,it is because we installed a vs2010 x86 version to a x64 system...
Open two folders:
C:\Windows\Microsoft.NET\Framework\v4.0.30319
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
You will find two cvtres.exe. Righ click, select Properties, then Details. Delete the older version, and cmake will work well.
I hope this may help you.
Thanks to "zhoudongao" # http://bbs.csdn.net/topics/390121452?page=1#post-394768226.
I know this is a bit dated but if anyone's looking for a way to get compiler running from command line; here's what I did to get it running.
I'm using Win7 32bit and Visual Studio 2010. I created a small batch file in C:\Windows. open cmd prompt at C:\Windows as admin, then type the following:
copy con cl.bat
#"C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32" %1 %2 %3 %4 %5 %6
#"C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\cl" %1 %2 %3 %4 %5 %6
then press f6 and hit enter again.
Obviously the path you will use is the install path to where you installed Visual Studio.
You now have working command line compiler from any location or directory in windows. To test this go to desktop and open cmd prompt as admin; I prefer to use Ctrl+Shift and right click then choose open command prompt here.
At command prompt type "cl" (without quotes) and hit enter. you will see a message "Setting enviroment for using Microsoft Visual Studio 2010 x86 tools"
type "cl" and hit enter again and you will get your compiler info. you're all set to compile.
enjoy!
Maybe it will help somebody...
I solved this problem by adding
PATH += %PATH_TO_VS_IN_YOUR_SYSTEM%/Common7/IDE;
to nvcc.profile.
Of course, %PATH_TO_VS_IN_YOUR_SYSTEM% is actual path to Visual Studio in your system.
Old, but maybe still valid:
For me "C:\Windows\System32" somehow got missing from the PATH variable.
Adding the missing folder to the path solved this error. See also VS2010 command prompt gives error : Cannot determine the location of the VS Common Tools folder
if you try to run the tools from the windows cmd.exe directly then you need to set the environments by running the vcvars32.bat file which will set the environment for you. instead you can run the visual studio command prompt which will run vcvars32.bat automatically. if you still have the problem then it's definitely the famous path variable problem.
make sure the "path" variable in the environment has the "c:\windows\system32\" value added to it , because the .bat file will need it to configure the VC tools.
this problem and the like usually happen because of installing many development platforms on the machine which might probably change the path variable.
check this..
https://schrievkrom.wordpress.com/2011/01/25/error-cannot-determine-the-location-of-the-vs-common-tools-folder/

How do I setup environment variable INCLUDE for Visual Studio 2005?

Is there a script that I can run that will setup my %INCLUDE% environment variable?
I'm running PC-lint and it can't find my include header files. I went through the documentation and it appears that I need to setup the %INCLUDE% environment variable.
I was wondering if there's an easy way to do it.
Visual Studio comes with a VCVARS32 (it might be renamed by now) batch file in its directory that will set all of these environment variables for you, and give you a shell with them set. It has a start menu entry, if you installed normally -- or maybe it came with the Platform SDK? It's been a while.
From the Microsoft documentation on the subject:
To run vcvars32.bat
At the command prompt, change to the \bin subdirectory of your Visual C++ installation.
Run vcvars32.bat by typing VCVARS32.
Barring that, you can permanently set your environment variables (per-system or per-user) in Control Panel, under System.

Resources