There is no such task in MSBuild Extension Pack or in MSBuild Community Tasks. But you could easily create a such one. Something like this:
using System.Diagnostics;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace StackOverflow.MSBuild
{
public class IsProcessRunning : Task
{
private string processName;
private bool isRunning;
[Required]
public string ProcessName
{
get { return processName; }
set { processName = value; }
}
[Output]
public bool IsRunning
{
get { return isRunning; }
}
public override bool Execute()
{
if(string.IsNullOrEmpty(processName))
{
Log.LogError("ProcessName could not be empty");
return false;
}
foreach(Process clsProcess in Process.GetProcesses())
{
if(clsProcess.ProcessName.Contains(processName))
{
isRunning = true;
}
}
return true;
}
}
}
And you use it like that:
<UsingTask AssemblyFile="$(Task_Assembly_path)"
TaskName="StackOverflow.MSBuild.IsProcessRunning" />
<Target Name="TestTask">
<IsProcessRunning ProcessName="${Process}">
<Output ItemName="Result" TaskParameter="IsRunning"/>
</IsProcessRunning>
<Message Text="Process ${Process} is running"
Condition="'${Result}' == 'true'"/>
</Target>