Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio 2017 Developer Command Prompt switches current directory

I am getting weird behavior of "Developer Command Prompt for VS 2017" command line tool. Normally in previous versions of visual studio this script (VsDevCmd.bat) was not messing current directory from where you run it. Now it seems to change it. One simple workflow would be just to start the shortcut "Developer Command Prompt for VS 2017" and it doesn't honor the "Start in" directory: enter image description here

By any chance anyone seen this issue? It really bugs me because I used to have a shortcut with it and start CMD in my source directory, use TFS/msbuild commands afterwards.

like image 645
void Avatar asked Oct 11 '17 07:10

void


2 Answers

You can set the VSCMD_START_DIR environment variable to have vsdevcmd.bat change to that directory when it finishes. Otherwise it will check if you have a %USERPROFILE%\source directory and change to that (which is what you see).

You can change the "Target" for the "Developer Command Prompt for VS 2017" to something like the following to have change to a particular directory:

%comspec% /k "set VSCMD_START_DIR=C:\temp && "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat""

Note that the path to vsdevcmd.bat needs to be put in an additional set of double quotes.

Alternatively, rename or remove the %USERPROFILE%\source directory (Note that this seems to be some kind of new "standard" directory for sources), that will make vsdevcmd.bat honor the "Start In"-value (i.e. "current directory").

like image 177
Christian.K Avatar answered Oct 09 '22 11:10

Christian.K


:: Some rocket scientist in Redmond made the VS15 VsDevCmd.bat change the cwd; the pushd/popd fixes that. pushd %CD% call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat" popd

"C:\Program Files (x86)\CruiseControl.NET\server\ccnet.exe" %*

like image 39
Kafka Avatar answered Oct 09 '22 11:10

Kafka