public string ChangeWorkingDirectory() { var currentWorkingDirectory = Directory.GetCurrentDirectory(); if (!string.IsNullOrEmpty(WorkingDirectory)) { Directory.SetCurrentDirectory(WorkingDirectory); } else if (!string.IsNullOrEmpty(Project)) { var workingDirectory = Path.GetDirectoryName(Project); if (Directory.Exists(workingDirectory)) { Directory.SetCurrentDirectory(workingDirectory); } } else if (AssemblyPaths.Any()) { var workingDirectory = Path.GetDirectoryName(AssemblyPaths.First()); if (Directory.Exists(workingDirectory)) { Directory.SetCurrentDirectory(workingDirectory); } } return(currentWorkingDirectory); }
protected async Task <TResult> RunIsolatedAsync(string configurationFile) { var assemblyDirectory = AssemblyPaths.Any() ? Path.GetDirectoryName(Path.GetFullPath(AssemblyPaths.First())) : configurationFile; var bindingRedirects = GetBindingRedirects(); var assemblies = GetAssemblies(assemblyDirectory); using (var isolated = new AppDomainIsolation <IsolatedCommandAssemblyLoader <TResult> >(assemblyDirectory, AssemblyConfig, bindingRedirects, assemblies)) { return(await Task.Run(() => isolated.Object.Run(GetType().FullName, JsonConvert.SerializeObject(this), AssemblyPaths, ReferencePaths)).ConfigureAwait(false)); } }