具有参数的简单Powershell Msbuild失败 [英] Simple Powershell Msbuild with parameter fails

查看:97
本文介绍了具有参数的简单Powershell Msbuild失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试传递一个简单的变量,

I am trying to pass a simple variable passing,

没有参数

msbuild MySolution.sln /p:Configuration=Debug /p:Platform="Any CPU"

尝试1

$buildOptions = '/p:Configuration=Debug /p:Platform="Any CPU"'
msbuild MySolution.sln + $buildOptions

->导致MSB1008

-> cause MSB1008

尝试2

$command = "msbuild MySolution.sln" + $buildOptions
Invoke-expression $command

->导致MSB1009

-> cause MSB1009

我在帖子中尝试了该解决方案,但我认为这是一篇不同的错误.

I tried the solution on this post but I think it is a different error.

推荐答案

尝试以下方法之一:

msbuild MySolution.sln $buildOptions

Start-Process msbuild -ArgumentList MySolution.sln,$buildOptions -NoNewWindow

顺便说一句,PowerShell v3中有一个针对这种情况的新功能,-%之后的所有内容均按原样处理,因此您的命令将如下所示:

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"

有关更多信息,请参见此帖子: http://rkeithhill.wordpress.com /2012/01/02/powershell-v3-ctp2-提供了更好的参数传递给exes/

See this post for more information: http://rkeithhill.wordpress.com/2012/01/02/powershell-v3-ctp2-provides-better-argument-passing-to-exes/

这篇关于具有参数的简单Powershell Msbuild失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆