I need to run MSBuild from the command line using the Visual Studio Command Prompt (2010). It used to work fine. Now when I open the window I get the following error message:
\Common was unexpected at this time.
Trying to run the msbuild
command after that fails.
I naturally assumed it was an issue with an unquoted entry in my PATH environment variable, possibly from a recent rogue install. I checked that, but the PATH seems to be kosher.
Digging into the file system, I discovered that the batch file being run by the prompt is C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat. I edited that by putting in ECHO
statements to trace the location of the error. That seemed to point to an error at this line:
@if not "%WindowsSdkDir%" == "" (
If I remove the quotation marks, the error is different: "Files was not expected at this time."
The next 2 lines after this are now:
@echo 51
@set "PATH=%WindowsSdkDir%bin\NETFX 4.0 Tools;%WindowsSdkDir%bin;%PATH%"
I assumed the failing statement was the second line, but the echo
statement doesn't produce any output, so I don't know how that could be happening.
I am using a 64-bit version of Windows 7.
I would appreciate any help at all.
See this thread.
My guess is your
PATH
got modified recently and now contains some folder path with quotation marks inside.HTH
I had quotation marks (") in the PATH variable that caused this, after I removed them it started working.
My problem was that inside of an if block the rval of a variable assignment (%PATH% in my case) contained a parentheses, for example:
Displays "got was unexpected at this time."
I found the answer here: Batch file variable with spaces and parentheses. Which is to use the extended syntax of set. For example:
This does not add quotes and does not affect the result stored in %var2%.