是否有包含为msbuild调用的原始目标的变量? 基本上在Visual Studio中,我只需要在发布时调用powershell脚本。
更新 在Alexey的回答之后,我已经尝试过了:
<Target Name="DeployToAzure" AfterTargets="CopyPackageToDropLocation">
<PropertyGroup>
<PowerShellExe Condition=" '$(PowerShellExe)'=='' ">
%SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe
</PowerShellExe>
</PropertyGroup>
<Exec Command="$(PowerShellExe) -ExecutionPolicy Unrestricted -noprofile -nologo " & { Write-Output 'Test' } "" />
</Target>
但是执行被卡住了。我把它放到输出窗口(然后永远挂起):
Task "Exec"
3> Task Parameter:Command=
3> %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe
3> -ExecutionPolicy Unrestricted -noprofile -nologo " & { Write-Output 'Test' } "
3>
3> %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe
3> -ExecutionPolicy Unrestricted -noprofile -nologo " & { Write-Output 'Test' } "
3> Windows PowerShell
3> Copyright (C) 2013 Microsoft Corporation. All rights reserved.
答案 0 :(得分:1)
不,没有这样的变量(据我所知)。但是要运行您的PowerShell脚本 - 您可以创建一个目标并将其与其他目标连接起来 - 例如在你的情况下,它就像
<Target Name="RunMyPowershell" AfterTargets="Publish">
..
</Target>
您还可以在脚本中检测是从msbuild还是从Visual Studio调用 - 请参阅有关$(BuildingInsideVisualStudio)的文章 https://msdn.microsoft.com/en-us/library/ms171468(en-us).aspx