2

I just want to run the following two lines.

cd SomeDirectory
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com 
   Source\MySolution.sln /build Release /project Source\My\Setup\Project.vdproj

If I wrap everything in quotes, nothing seems to happen other than the strings printing to the console.

O.O
  • 11,077
  • 18
  • 94
  • 182

1 Answers1

4

When quoting a path to a program to run it you need to prepend &:

& "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com" Source\MySolution.sln /build Release /project Source\My\Setup\Project.vdproj"

The reason being that PowerShell has two different parsing modes: command mode and expression mode. But the quoted string will switch to expression mode, thus you explicitly need the call operator, &.

Another thing: You may have to use a full path for the arguments because PowerShell has a different notion of a current directory, that native programs don't share.

Joey
  • 344,408
  • 85
  • 689
  • 683
  • How to include the full path with "" in Source\MySolution.sln ? – Yiping Sep 20 '17 at 07:36
  • 1
    @Yiping: You surround it with quotes if necessary. Note that PowerShell will still parse arguments and quote arguments to external programs based on its own rules. Using `--%` (cf. `Get-Help about_parsing`) can help. – Joey Sep 20 '17 at 07:48