Is there a variable containing the original target invoked for msbuild? Basically in Visual Studio I'd need to call a powershell script only on publish.
Update: After Alexey's answer, I've tried this:
<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>
But the execution gets stuck. I get this into the output window (and then hangs forever):
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.