private void LoadProjectAssembly() { if (string.IsNullOrEmpty(AssemblyFilename)) { Output.WriteLine("No assembly filename defined!", ConsoleColor.DarkRed); throw new ApplicationException("Assembly filename is undefined!"); } if (!string.IsNullOrWhiteSpace(PreBuild)) { Output.WriteLine("Running Pre-Build Script...", ConsoleColor.DarkCyan); try { RunCommandScript(PreBuild); } catch (Exception error) { Output.WriteLine($"An error occurred while executing the Pre-Build script! {error.Message} [{SessionId}]", ConsoleColor.DarkYellow); throw new ApplicationException($"Script Pre-Build failed! [{SessionId}]", error); } } var assemblyFilename = Path.Combine(ContentDirectory, AssemblyFilename); if (!File.Exists(assemblyFilename)) { Output.WriteLine($"The assembly file '{assemblyFilename}' could not be found!", ConsoleColor.DarkYellow); throw new ApplicationException($"The assembly file '{assemblyFilename}' could not be found!"); } // Shadow-Copy assembly folder string assemblyCopyFilename; try { var sourcePath = Path.GetDirectoryName(assemblyFilename); var assemblyName = Path.GetFileName(assemblyFilename); assemblyCopyFilename = Path.Combine(BinDirectory, assemblyName); CopyDirectory(sourcePath, BinDirectory); } catch (Exception error) { Output.WriteLine($"Failed to shadow-copy assembly '{assemblyFilename}'!", ConsoleColor.DarkYellow); throw new ApplicationException($"Failed to shadow-copy assembly '{assemblyFilename}'!", error); } try { Domain = new AgentSessionDomain(); Domain.Initialize(assemblyCopyFilename); } catch (Exception error) { Output.WriteLine($"An error occurred while initializing the assembly! {error.Message} [{SessionId}]", ConsoleColor.DarkRed); throw new ApplicationException($"Failed to initialize Assembly! [{SessionId}]", error); } }
private void LoadProjectAssembly() { if (!File.Exists(AssemblyFilename)) { Output.WriteLine($"The assembly file '{AssemblyFilename}' could not be found!", ConsoleColor.DarkYellow); throw new ApplicationException($"The assembly file '{AssemblyFilename}' could not be found!"); } try { Domain = new AgentSessionDomain(); Domain.Initialize(AssemblyFilename); } catch (Exception error) { Output.WriteLine($"An error occurred while initializing the assembly! {error.Message} [{SessionId}]", ConsoleColor.DarkRed); throw new ApplicationException($"Failed to initialize assembly! [{SessionId}]", error); } }
private void LoadProjectAssembly() { if (string.IsNullOrEmpty(AssemblyFilename)) { Output.WriteLine("No assembly filename defined!", ConsoleColor.DarkRed); throw new ApplicationException("Assembly filename is undefined!"); } var errorList = new Lazy <List <Exception> >(); var abort = false; var preBuildScript = PreBuild; if (!string.IsNullOrWhiteSpace(preBuildScript)) { Output.WriteLine("Running Pre-Build Script...", ConsoleColor.DarkCyan); try { RunCommandScript(preBuildScript); } catch (Exception error) { errorList.Value.Add(new ApplicationException($"Script Pre-Build failed! [{SessionId}]", error)); //Log.Error($"Script Pre-Build command failed! [{Id}]", error); Output.WriteLine($"An error occurred while executing the Pre-Build script! {error.Message} [{SessionId}]", ConsoleColor.DarkYellow); abort = true; } } var assemblyFilename = Path.Combine(ContentDirectory, AssemblyFilename); if (!File.Exists(assemblyFilename)) { errorList.Value.Add(new ApplicationException($"The assembly file '{assemblyFilename}' could not be found!")); Output.WriteLine($"The assembly file '{assemblyFilename}' could not be found!", ConsoleColor.DarkYellow); abort = true; } // Shadow-Copy assembly folder string assemblyCopyFilename = null; try { var sourcePath = Path.GetDirectoryName(assemblyFilename); var assemblyName = Path.GetFileName(assemblyFilename); assemblyCopyFilename = Path.Combine(BinDirectory, assemblyName); CopyDirectory(sourcePath, BinDirectory); } catch (Exception error) { errorList.Value.Add(new ApplicationException($"Failed to shadow-copy assembly '{assemblyFilename}'!", error)); Output.WriteLine($"Failed to shadow-copy assembly '{assemblyFilename}'!", ConsoleColor.DarkYellow); abort = true; } if (!abort) { try { Domain = new AgentSessionDomain(); Domain.Initialize(assemblyCopyFilename); } catch (Exception error) { errorList.Value.Add(new ApplicationException($"Failed to initialize Assembly! [{SessionId}]", error)); Output.WriteLine($"An error occurred while initializing the assembly! {error.Message} [{SessionId}]", ConsoleColor.DarkRed); //abort = true; } } if (errorList.IsValueCreated) { throw new AggregateException(errorList.Value); } }