1

I'm trying to run this command while embedding the env.JOB_BASE_NAME variable like so:

bat '"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\amd64\\MSBuild.exe" "C:\\jenkins\\workspace\\${env.JOB_BASE_NAME}\\MySolution.sln"'

I tried the answer suggested on this question but that solution doesn't work for me. If I remove the single quotes as was suggested in the other answer, I get this error:

'C:\Program' is not recognized as an internal or external command, program or batch file.

Presumably because of the space between 'Program' and 'Files'.

I've tried wrapping it in triple double quotes, and various other solutions, with no luck. What is the proper way to do this?

Hoser
  • 4,974
  • 9
  • 45
  • 66
  • 1
    try escaping the sapces with carrot symbol , example: C:\>cd Documents^ and^ Settings. So in your case C:\\Program Files^ (x86). Another solution , you can put them between double quotes , example/; C:\\"Program Files (x86)"\\etc... – mbn217 Jan 30 '19 at 21:42
  • @mbn217 Good idea but didn't work unfortunately, still got the same error – Hoser Jan 30 '19 at 21:52

1 Answers1

2

Figured it out myself. I have to triple double quote and then put double quotes around the commands as well.

bat  """ "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\amd64\\MSBuild.exe" "C:\\jenkins\\workspace\\${env.JOB_BASE_NAME}\\MySolution.sln" """
Hoser
  • 4,974
  • 9
  • 45
  • 66