5

I am trying to run the following command in PowerShell

PS C:\Users\Administrator> cmd /c "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\vsdevcmd.bat && nuget restore && msbuild mywebapp.sln /p:DeployOnBuild=true /p:PublishedProfile=ServerFolderProfile"

This produces the error

'C:\Program' is not recognized as an internal or external command. 

My paths have spaces and I'm running several commands seperated by && which is messing everything up. I have tried putting quotes all over the place but I can't get it to work.

If i run just the first part of the command

cmd /c "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\vsdevcmd.bat"

it works fine. But I can't get the other commands to work too.

1 Answer 1

6

According to the docs for cmd.exe:

If /C or /K is specified, then the remainder of the command line is processed as an immediate command in the new shell. Multiple commands separated by the command separator & or && are accepted if surrounded by quotes

So I just had to change my command to:

PS C:\Users\Administrator> cmd /c "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\vsdevcmd.bat" "&&" nuget restore "&&" msbuild mywebapp.sln /p:DeployOnBuild=true /p:PublishedProfile=ServerFolderProfile
Sign up to request clarification or add additional context in comments.

2 Comments

You should flag your answer as the answer to this question so that it is not left 'unanswered' - if you can.
@AdamParsons When I try I get a message that says I have to wait until tomorrow. So I will do it then.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.