public override void ExecuteRecursive(TaskExecutionNode node) { var task = (RunAssemblyTask)node.RemoteTask; var priorCurrentDirectory = Environment.CurrentDirectory; try { // Use the assembly in the folder that the user has specified, or, if not, use the assembly location var assemblyFolder = GetAssemblyFolder(TaskExecutor.Configuration, task); var assemblyPath = new AssemblyPath(Path.Combine(assemblyFolder, GetFileName(task.AssemblyLocation))); Environment.CurrentDirectory = assemblyFolder; var listener = new PerAssemblyRunListener(Server, task); var contextList = new List <string>(); node.Flatten(x => x.Children).Each(children => RegisterRemoteTaskNotifications(listener, children, contextList)); var runOptions = RunOptions.Custom.FilterBy(contextList); var appDomainRunner = new AppDomainRunner(listener, runOptions); if (TaskExecutor.Configuration.ShadowCopy) { string cachePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); runOptions.ShadowCopyTo(cachePath); this.Server.SetTempFolderPath(cachePath); } appDomainRunner.RunAssembly(assemblyPath); } finally { Environment.CurrentDirectory = priorCurrentDirectory; } }
void RegisterRemoteTaskNotifications(PerAssemblyRunListener listener, TaskExecutionNode node, ICollection <string> contexts) { listener.RegisterTaskNotification(TaskNotificationFactory.CreateTaskNotification(node, contexts)); }