Visual Studio Command Prompt gives “\Common was un

2020-04-02 05:38发布

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.

3条回答
爷的心禁止访问
2楼-- · 2020-04-02 05:57

See this thread.

My guess is your PATH got modified recently and now contains some folder path with quotation marks inside.

HTH

查看更多
Root(大扎)
3楼-- · 2020-04-02 06:03

I had quotation marks (") in the PATH variable that caused this, after I removed them it started working.

查看更多
做个烂人
4楼-- · 2020-04-02 06:09

My problem was that inside of an if block the rval of a variable assignment (%PATH% in my case) contained a parentheses, for example:

set var=foo ) got ya

if 1 == 2 (
    set var2=%var%
)

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:

set "var2=%var%"

This does not add quotes and does not affect the result stored in %var2%.

查看更多
登录 后发表回答