1

I have Jenkins freestyle jobs that successfully invoke msbuild jobs using the VS 2015 tools by declaring environment variable:

VSMSBUILDCMD_14_0="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsMSBuildCmd.bat"

and setting the environment by calling from a bat step:

call %VSMSBUILDCMD_14_0%

However, if I try to do similar using the VS 2017 tools I get an expected error:

VSMSBUILDCMD_14_1="C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\Common7\\Tools\\VsMSBuildCmd.bat"

call %VSMSBUILDCMD_14_1%

c:\jenkins\workspace\aa_test>call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsMSBuildCmd.bat"

\Java\jre1.8.0_161\bin"" was unexpected at this time.

I get the same result even if I use shortened directory names:

VSMSBUILDCMD_14_1="C:\\PROGRA~2\\MIB055~1\\2017\\BuildTools\\Common7\\Tools\\VsMSBuildCmd.bat"

CALL %VSMSBUILDCMD_14_1%

CALL "C:\PROGRA~2\MIB055~1\2017\BuildTools\Common7\Tools\VsMSBuildCmd.bat" 
\Java\jre1.8.0_161\bin"" was unexpected at this time.

This question may be related: How to solve JDK issue unexpected at this time

but I haven't managed to fix my problem.

Any suggestions please?

DavidA
  • 2,053
  • 6
  • 30
  • 54

1 Answers1

-1

You probably have a JAVA_HOME environment variable set to c:\Program Files\Java\jre1.8.0_161. Try using shortnames with that.

set JAVA_HOME="c:\PROGRA~1\Java\jre1.8.0_161" "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsMSBuildCmd.bat"

Sean McEligot
  • 307
  • 1
  • 4
  • Hi Sean, JAVA_HOME is not set: '>set JAVA_HOME' gives 'Environment variable JAVA_HOME not defined' – DavidA Apr 23 '18 at 07:49
  • maybe your PATH? It looks like something being called from VsMSBuildCmd.bat is not handling spaces correctly. – Sean McEligot Apr 24 '18 at 17:32
  • Thanks, yes clearing PATH fixed the problem. Perhaps one of the Java paths there was causing it. If you want to add this as another answer, I'll accept it. – DavidA Apr 25 '18 at 10:57