Run MSBuild from PowerShell

Viewed 13279

I have the following code in a PowerShell file:

$msbuild = 'C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe'
iex ("& {0} {1}" -f $msbuild, "-version")

The error I get is:

x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I've tried a number of things but I can't get PowerShell to work using string variables in the script. My more general goal is to run scripts of the nature of

iex ("{0} {1} {2}" -f $msbuild,$project_name,$config)
1 Answers
Related