简体   繁体   中英

Running cmd /c from a PowerShell ps1 script using Stop-Parsing

I have been stuck on this for ages. I am trying to run the following command from a .ps1 file

  cmd --% /c "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" "&&" nuget restore "&&" msbuild mywebapp.sln /p:DeployOnBuild=true /p:PublishProfile=ServerFolderProfile

But I keep getting the following error

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

I figured out how to run the command from a PowerShell window from a previous question .

Also, the Stop-Parsing --% symbol requires at least Version 3 of PowerShell and I am running version 5.1.

Forget about --% . Put quotes around the entire commandline you want to run in CMD and escape the nested double quotes around the path to the batch file.

cmd /c "`"C:\Pro...Cmd.bat`" && nuget restore && msbuild mywebapp.sln /p:DeployOnBuild=true /p:PublishProfile=ServerFolderProfile"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM