从powershell执行msbuild任务
我关注这个博客: 这个问题的答案是: 每个步骤都按照所述工作,但我想从powershell脚本调用转换。 我想在powershell从powershell执行msbuild任务,msbuild,powershell-2.0,Msbuild,Powershell 2.0,我关注这个博客: 这个问题的答案是: 每个步骤都按照所述工作,但我想从powershell脚本调用转换。 我想在powershellmsbuild trans.proj/t:Demo中执行此命令 我发现一些论坛说我应该使用invoke expression 当我尝试时,我得到了这个错误 Powershell: Invoke-Expression $msbuild transformCommand.proj /t:Demo 结果 Invoke-Expression : Cannot bind a
msbuild trans.proj/t:Demo中执行此命令
我发现一些论坛说我应该使用invoke expression
当我尝试时,我得到了这个错误
Powershell:
Invoke-Expression $msbuild transformCommand.proj /t:Demo
结果
Invoke-Expression : Cannot bind argument to parameter 'Command' because it is null.
At D:/Somewhere
+ Invoke-Expression <<<< $msbuild transformCommand.proj /t:Demo
+ CategoryInfo : InvalidData: (:) [Invoke-Expression], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.InvokeExpre
ssionCommand
结果
D:\Somewhere
Invoke-Expression : A positional parameter cannot be found that accepts argument 'transformCommand.proj'.
At D:\Redgate\Communited.Timeblockr.Api\PreDeploy1.ps1:14 char:18
+ Invoke-Expression <<<< msbuild transformCommand.proj /t:Demo
+ CategoryInfo : InvalidArgument: (:) [Invoke-Expression], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeExpressionCommand
这实际上是我需要的一切
不过,如果有更多“独立”或更好的方法来实现此目的,请发布它。在调用调用表达式$msbuild之前,请确保按如下所示定义PowerShell变量$msbuild
$msbuild = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"
我最后做了以下工作来构建一个具有多个参数的解决方案
&$msbuildExe ('solution.sln','/verbosity:q','/p:configuration=Release','/t:Clean,Build')
if (!$?) {
echo "!!! ABORTING !!!";pause;exit
}
$a = "Path\transformCommand.proj /t:Demo"
#Invoke-Expression $msbuild $a
Start-Process -FilePath "C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" -ArgumentList $a | Write-Host
$msbuild = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"
&$msbuildExe ('solution.sln','/verbosity:q','/p:configuration=Release','/t:Clean,Build')
if (!$?) {
echo "!!! ABORTING !!!";pause;exit
}