Visual Studio 2012 Command Prompt expected environment pathway not included - visual-studio

Recently installed (and re-installed) VS 2012 Ultimate with Blend
The VS Command Prompt doesn't seem to have a reference (are they called environment pathways) to the folder "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\". This means the following lines won't run from the command prompt (either as normal or as administrator)
msbuild buildapp.csproj /t:HelloWorld
Installutil WindowsService1.exe
To use msbuild or Installutil I need to specify the full pathways for the above to run.
Is the above a by design change that MS have made to VS?

In my VS 2012 environment I can find the path you say is missing. I opened the "Developer Command Prompt for VS2012" and did PATH to verify and also ran InstallUtil.exe successfully.
Make sure you open the correct prompt, mine was started using %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat"

Here's Microsoft's explanation (err..justification :)) of the convoluted path structure :
For 32 bit builds :
Setting the Path and Environment Variables for Command-Line Builds
.. and 64 bit builds :
How to: Enable a 64-Bit Visual C++ Toolset on the Command Line

Related

Visual Studio Exe App compilation path change

I just want to change the exe file Visual Studio compilation path change
I am doing it like this now. i created a bat file that copied file. I have added visual studio build events. I wonder if there is an easier way.
meanwhile the exe file is being copied to the network drive
I had this problem in a different context (Elixir/Phoenix, Rust), but the root cause was the same: cl.exe could not be found during compilation.
My setup was:
Windows 10, x64
Visual Studio Community 2017 already installed, but only for C# development
For some reason the solution with installing the Visual C++ Build Tools (as #cozzamara suggested) did not work. Stops during installation with some obscure error message. Guess it did not liked my existing Visual Studio installation.
This is how I solved it:
Start up the Visual Studio Installer
Check the Desktop development with C++ (screenshots here)
Execute following command before compiling:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
From this on the command cl.exe works. Alternatively (and more conveniently for development) start the application 'Developer Command Prompt for VS 2017' or 'x64 Native Tools Command Prompt VS 2017'.
Share
I solved the problem by writing code like this in the Post build field, I just ensured that the exe was copied to the field I wanted
COPY $(TargetPath) "\x.x.x.x\ortak\yakup\TestApp.exe"
pause
$(TargetPath) = It gives the location where the exe exited, along with the exe name
"C:\yakup\project\TestApp.exe" like

VC++ cl.exe -- DLL not found

I added the bin directory of the VS2010 (not SP1) C++ compiler to my PATH variable on Windows XP. When i try to run it, it tells me that a DLL was not found.
I added this line to my PATH:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin;
Update: it still fails when I cd to the bin directory above, and then run the compiler
Can you help me out?
Run the VS command prompt shortcut or the batch file it points to, such as:
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
to set up an appropriate environment including the path.
By the way, mspdb100.dll lives in C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE. But run the shortcut/batch file anyway - it does more than set up the correct path.
add Microsoft Visual Studio 10.0\Common7\IDE to your Path variable, than close cmd prompt and open it. now it will work.
Running the VS command prompt takes care of setting up the environment. Also, ensure that you are running the command prompt as an admin.
Installing Visual Studio 2010 SP1 C++ Compiler Setup fixed this issue for me. Visual Studio 2010 SP1 C++ Compiler install
I faced the same issue when I tried to run a 32 bit exe I built, on a 64 bit machine.
"mspdb100.dll couldn't be found by cl.exe "
Visual Studio 2010(the version I currently use) builds a 32 bit exe by Default.To create a 64 bit executable, just change the setting from Win32 to x64 in the dropdown box at the top of VS and build.This will build for you a 64 bit executable and solve your problem.

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/

Visual Studio Command Prompt vs. a regular command prompt?

When I open a Visual Studio command prompt (for example, opened with menu Start -> Programs -> Microsoft Visual Studio 2008 -> Visual Studio Tools -> Visual Studio 2008 Command Prompt), I get:
Setting environment for using Microsoft Visual Studio 2008 x86 tools.
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE>
What kind of tools are available, and what are the most common uses of this command prompt?
It basically just sets several of the Visual Studio binary locations into the PATH environment variable for that command window instance. This means you can use all the various commands and tools without having to include the full paths.
There's a partial list of some of the tools available on MSDN in .NET Framework Tools and Tools (.NET Framework).
The Visual Studio command prompt is a convenient way to access the command line tools that ship with the .NET Framework SDK and, if installed the, Windows Platform SDK tools.
By providing the Visual Studio command prompt, Microsoft allows you to run these tools without requiring your PATH, INCLUDE, LIB and LIBPATH environment variables to contain all the additional paths to the various folders where Visual Studio and the .NET SDK are installed. Instead, these folder references are added on the fly when you start the Visual Studio command prompt allowing you to run the tools.
For example, if you open a regular command prompt you cannot run xsd.exe without changing to the directory "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin". However, in the Visual Studio command prompt you can just type xsd.exe /?, and it works.
Please see the MSDN article .NET Framework Tools for a complete list of the tools provided with Visual Studio 2008 SP1 and details on what they do.
The Visual Studio command prompt has a few tools with it. Some tools are for repairing the install of Visual Studio. One of the tools I love using is for WCF. You type wcftestclient and you get a client to test your WCF services.
The article The Visual Studio Command Prompt has a nice explanation:
Let's look at the "Visual Studio Command Prompt" in more detail.
It appears to just set the path for you and put you in (Ta Da!) the VC
directory under Visual Studio. Not even the C# directory and certainly
not the VB directory. I guess they assume that anyone who uses this
tool is really hard core and programs directly against the hard drive
with a magnifying glass and a magnet.
What it actually does is run this DOS command. (In my case.)
%comspec% /k ""C:\Program Files\Microsoft Visual Studio
10.0\VC\vcvarsall.bat"" x86
What does vcvarsall.bat do? Well, it sets the target compiler
environment so you can compile code for a different processor.
One use seems to be to call the XML Class Generator for using XSD schemas for serialization/deserialization:
XML Class Generator for C# using XSD for deserialization
Simple example
After installing Desktop development with C++ as part of the VS Installer, it installs C++ CMake tools for Windows. Let's run this cmake.exe file!
VS Developer Command Prompt
C:\Directory>cmake --version
cmake version 3.21.21080301-MSVC_2
Windows Command Prompt
C:\Directory>cmake --version
'cmake' is not recognized as an internal or external command,
operable program or batch file.
Why example behaves as it does
The VS Developer Command Prompt knew the command cmake, yet the Windows command prompt didn't.
Its almost as if it is and isnt a path variable - Schrodingers cat, errr path!
So where is cmake.exe that the VS developer command prompt says it knows about?
VS Developer Command Prompt
C:\Directory>where cmake
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
Okay so that means C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\ must be a PATH variable.
Lets double check:
C:\Directory>set PATH
Path=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;
It is, great. Now why didnt the windows command prompt find it?
Windows Command Prompt
C:\Directory>set PATH
Hmmm, I'm looking at the list and its not there.
Now Simon Steven's and MikeD's answer can be put in context:
It basically just sets several of the Visual Studio binary locations into the PATH environment variable for that command window instance. This means you can use all the various commands and tools without having to include the full paths.

Starting Visual Studio from a command prompt

I have three different versions of Visual Studio installed on my machine,
Visual Studio 2003, Visual Studio 2008, and VS2005.
How do I start a particular version of Visual Studio using a command prompt?
devenv.exe opens the latest version of Visual Studio. What should I do if I want to open Visual Studio 2003 using a command prompt?
Haven't tested on preceding versions - but to launch Visual Studio 2019 you can just enter start devenv to launch right away without entering into a path
You have to use the path to distinguish them. For instance, here is the Visual Studio 2005 command on my laptop:
"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
Here's another tip: You can figure out how to run various Windows applications from the command line by finding them in the Windows Start Menu, right-clicking on the icon, select properties, and then on the Shortcut tab, look at the Target textbox. Copy that text out and usually you can use it at a console command line.
This answer is a different way to handle starting Visual Studio in any version of Windows, by using the Windows Key {windows logo} start to start the target application.
Pin each version to the task bar. One way is to right click an active running program and select 'Pin to Taskbar. Or find in the program manager and right click again to pin.
Pin each different version right next to the task bar. For this example pin each version in succession 2003, 2005 and finally 2008. Make sure they are next to the start button for easier index number memorization.
To launch the 2003 version hit the WindowsKey then number 1.
To launch 2005 WindowsKey 2.
To launch 2008 WindowsKey 3.
This is fast and easy and can launch multiple instances without bringing up the command console.
Use devenv.exe for the specific version of Visual Studio. There will be one located in the Common7\IDE folder of the install. Here are the directories as I remember for the various versions.
2008:
%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\Ide\devenv.exe
2005:
%ProgramFiles%\Microsoft visual Studio 8\Common7\Ide\devenv.exe
For Visual Studio on a mac, you can:
open '/Applications/Visual Studio.app' [path_to].sln
I create an alias in my bash_profile so I can just navigate to a directory and open it in VS:
echo "alias vs=\"open '/Applications/Visual Studio.app' *.sln\"" >> ~/.bash_profile
Here is the shortcut, You can just type devenv.exe and start visual studio
You can also use the "Visual Studio 2005 Command Prompt" and "Visual Studio 2008 Command Prompt" to load a version-specific command shell environment, and then run devenv. This is typically found under Start -> Programs -> Visual Studio -> Visual Studio Tools
If you can't or don't want to access it via the Start menu, you can also "load" the VS-version specific environment in a normal command shell using the following (for VS 2008,
with a default install path): (note: change x86 as appropriate for your platform)
(32 bit) %comspec% /k ""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86
(64 bit) %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86
or for VS 2008 (with default install path):
(32 bit) %comspec% /k ""C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86
(64 bit) %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86
Each sets the environment so if you then subsequently execute devenv it'll load the correct version.
Put C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\ in the path of your computer.
Then open a new command prompt.
Change the directory to your project folder.
Type devenv to open the project in Visual Studio from the command prompt. This opens the project up in folder view. It has to have a .sln file to do the next part.
Click the switch views drop-down arrow and choose the .sln file.
The solution explorer will now display the solution.
Use an abolute path, for example, C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe.
1) devenv (to open VS)
2) devenv *.sln (then tab to autocomplete and enter to open VS and auto-load current solution)
By default, this only works in Developer Command Prompt.
To make it work in a normal console (I use cmder) you need to add folder path to devenv.exe to the System environment variable name Path.
For me that is this one:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE
You can also use this script and save it as vs.bat and then it will find for you *.sln file in the folder and automatically open visual studio with solution loaded (as in 2.)
Similar question where I answered: Visual studio: How to open a specific solution directly from command line?
Essentially use OpenVSSolution
Put this helper exe somewhere in your PATH
The exe scans the current directory for a .sln file
The exe opens devenv passing in the sln file
The explanation is on here: https://davemateer.com/coding/2018/11/14/Publish-dot-net-core-console-application.html
I find this incredibly useful and is how I open all solutions.
Use Window Terminal (https://github.com/microsoft/terminal), run these commands in the terminal
cd your-project-folder
.\your-solution.sln
I tried the answer that has been accepted in this question but it didnt work for me
I was able to launch Visual studio from RUN by typing devenv.exe in it.
WIN+R didnt work for opening RUN, so in command prompt, I typed the below path in command prompt
c:\WINDOWS\system32\rundll32.exe shell32.dll`,#61
use this command:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe
You can create a bat script for any visual studio version. You can find my script below.
start /B "" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe"
Even, you can create an alias following this post
Go to your project directory in cmd. (ex. cd <=FOLDER_PATH=>)
type code and press enter.
To open it with Visual Studio Express 2012 for Windows Desktop do -
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat""
%comspec% is:
C:\Users\Admin>echo %comspec%
C:\Windows\system32\cmd.exe
Or just search "developer" in the Windows 8 Start Search "Apps" menu, and it will lead you to "Developer Command Prompt for VS2012".

Resources