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?