private bool ExecuteDistribution(DistributionItem distribution, bool Copy, bool Start, Executor executor, FileInfo copyExe) { if (!Copy && !Start) { return(false); } Task task = null; string target = _ViewModel.GetSetting(distribution.Folder, Setting.Scopes.DistributionTarget); if (target.Count() == 0) { AddToLog($"No folder defined for DistributionTarget {distribution.Folder}\n"); return(false); } if (Copy) { string source = _ViewModel.DistributionSourceMap[distribution.Source]; target = target.Replace(@"{Platform}", distribution.Platform); target = target.Replace(@"{Configuration}", distribution.Configuration); target = target.Replace(@"{Name}", distribution.Folder); source = source.Replace(@"{Platform}", distribution.Platform); source = source.Replace(@"{Configuration}", distribution.Configuration); AddToLog($"Copy\n{source} -> {target}" + Environment.NewLine); InvalidateVisual(); Distributor distributeExecution = new Distributor() { copyExe = copyExe.ToString(), source = source, target = target, AddToLog = AddToLog }; task = executor.Execute(action => { distributeExecution.Copy(action); }); } if (Start) { if (task != null) { Task.WaitAll(task); } target = target.Replace(@"{Platform}", distribution.Platform); target = target.Replace(@"{Configuration}", distribution.Configuration); target = target.Replace(@"{Name}", distribution.Folder); string exe = distribution.Executable; if (exe.Count() == 0) { AddToLog($"No file defined for DistributionExe {distribution.Folder}\n"); return(false); } FileInfo exePath = new FileInfo(target + Path.DirectorySeparatorChar + exe); if (!exePath.Exists) { AddToLog($"Executable for starting does not exist: {exePath.ToString()}"); return(false); } AddToLog($"Execute {exePath} {distribution.SelectedExecArgument}" + Environment.NewLine); task = Task.Factory.StartNew(() => { System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = exePath.ToString(); process.StartInfo.Arguments = distribution.SelectedExecArgument; process.Start(); distribution.Proc = process; }); } return(true); }