/// <summary> /// Executes the task /// </summary> /// <returns></returns> public override bool Execute() { var sb = new StringBuilder(); sb.Append(MsTestPath); //Add test containers if (TestAssemblyPaths != null) { foreach (var assemblyPath in TestAssemblyPaths.Select(taskItem => taskItem.ItemSpec)) { sb.AppendFormat("/testcontainer:\"{0}\" ", assemblyPath); } } //Add test run config if (!string.IsNullOrEmpty(TestRunConfigPath)) { sb.AppendFormat("/runconfig:\"{0}\"", TestRunConfigPath); } Trace.WriteLine("Executing command: " + sb); var exec = new Microsoft.Build.Tasks.Exec { BuildEngine = BuildEngine, Command = sb.ToString() }; return(exec.Execute()); }
/// <summary> /// Executes SSOManage with a set of arguments /// </summary> /// <param name="arguments"></param> protected void ExecuteSsoManage(string arguments) { var exec = new Microsoft.Build.Tasks.Exec { BuildEngine = BuildEngine, Command = "\"" + SSOManagePath + "\" " + arguments }; exec.Execute(); }
/// <summary> /// Executes BTTDeploy with a set of arguments /// </summary> /// <param name="arguments"></param> protected bool ExecuteBttDeploy(string arguments) { var exec = new Microsoft.Build.Tasks.Exec { BuildEngine = BuildEngine, Command = "\"" + BttDeployPath + "\" " + arguments }; if (!string.IsNullOrEmpty(ManagementDb)) { exec.Command += string.Format(" /mgdb {0}", ManagementDb); } return(exec.Execute()); }
/// <summary> /// Executes BM.exe with a set of arguments /// </summary> /// <param name="arguments"></param> protected bool ExecuteBm(string arguments) { var exec = new Microsoft.Build.Tasks.Exec { BuildEngine = BuildEngine, Command = "\"" + BmPath + "\" " + arguments }; if (!string.IsNullOrEmpty(Database)) { exec.Command += string.Format(" -Database:{0}", Database); } if (!string.IsNullOrEmpty(Server)) { exec.Command += string.Format(" -Server:{0}", Server); } Trace.WriteLine("Executing command: " + exec.Command); return(exec.Execute()); }
public static bool Execute( #region Parameters System.String Command, out System.Int32 ExitCode, System.String Message = null, System.String RedirectStdOut = null, System.String RedirectStdErr = null, System.String WorkingDirectory = null, Microsoft.Build.Framework.ITaskItem[] Inputs = null, Microsoft.Build.Framework.ITaskItem[] Outputs = null, System.String RemoteTarget = null, System.String RemoteProjectDir = null, System.Boolean IgnoreExitCode = false) #endregion { #region Code if (!string.IsNullOrEmpty(Message)) { Log.LogMessage(MessageImportance.High, Message); } Command = "(" + Command + ")"; if (RedirectStdOut == "NUL" || RedirectStdOut == "/dev/null") { Command += " 1> NUL"; } else if (!string.IsNullOrEmpty(RedirectStdOut)) { Command += " 1> " + RedirectStdOut; } if (RedirectStdErr == "NUL" || RedirectStdErr == "/dev/null") { Command += " 2> NUL"; } else if (RedirectStdErr == "STDOUT") { Command += " 2>&1"; } else if (!string.IsNullOrEmpty(RedirectStdErr)) { Command += " 2> " + RedirectStdErr; } var taskExec = new Microsoft.Build.Tasks.Exec() { BuildEngine = BuildEngine, HostObject = HostObject, WorkingDirectory = WorkingDirectory, Command = Command, IgnoreExitCode = IgnoreExitCode, }; Log.LogMessage("\r\n==== HostExec: Microsoft.Build.Tasks.Exec"); Log.LogMessage("WorkingDirectory: {0}", taskExec.WorkingDirectory); Log.LogMessage("Command: {0}", taskExec.Command); bool ok = taskExec.Execute(); Log.LogMessage("== {0} ExitCode: {1}\r\n", ok ? "OK" : "FAIL", taskExec.ExitCode); ExitCode = taskExec.ExitCode; if (!ok) { return(false); } #endregion return(true); }