I am trying to pass a simple variable passing,
No parameter
msbuild MySolution.sln /p:Configuration=Debug /p:Platform="Any CPU"
Try 1
$buildOptions = '/p:Configuration=Debug /p:Platform="Any CPU"'
msbuild MySolution.sln + $buildOptions
-> cause MSB1008
Try 2
$command = "msbuild MySolution.sln" + $buildOptions
Invoke-expression $command
-> cause MSB1009
I tried the solution on this post but I think it is a different error.
Try one of these:
msbuild MySolution.sln $buildOptions
Start-Process msbuild -ArgumentList MySolution.sln,$buildOptions -NoNewWindow
By the way, there's a new feature in PowerShell v3 just for this kind of situations, anything after --% is treated as is, so you're command will look like:
msbuild MySolution.sln --% /p:Configuration=Debug /p:Platform="Any CPU"
See this post for more information: http://rkeithhill.wordpress.com/2012/01/02/powershell-v3-ctp2-provides-better-argument-passing-to-exes/
You need to put a space somewhere between MySolution.sln
and the list of parameters. As you have it, the command line results in
msbuild MySolution.sln/p:Configuration=Debug /p:Platform="Any CPU"
And MSBuild will consider "MySolution.sln/p:Configuration=Debug" to be name of the project/solution file, thus resulting in MSB10009: Project file does not exist.
.
You need to make sure that the resulting command line is something like this (note the space after MySolution.sln
:
msbuild MySolution.sln /p:Configuration=Debug /p:Platform="Any CPU"
There are plenty of ways to assure that using Powershell syntax, one of them is:
$buildOptions = '/p:Configuration=Debug /p:Platform="Any CPU"'
$command = "msbuild MySolution.sln " + $buildOptions # note the space before the closing quote.
Invoke-Expression $command
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With