public CommandResult Execute() { try { _fileSystemMigrator.Migrate(); var assemblyPaths = Enumerable.Empty <string>(); var workingDirectory = _fileSystem.GetWorkingDirectory(_script); if (workingDirectory != null) { assemblyPaths = _assemblyResolver.GetAssemblyPaths(workingDirectory); } _composer.Compose(workingDirectory); _scriptExecutor.Initialize(assemblyPaths, _scriptPackResolver.GetPacks(), ScriptArgs); var scriptResult = _scriptExecutor.Execute(_script, ScriptArgs); var commandResult = Inspect(scriptResult); _scriptExecutor.Terminate(); return(commandResult); } catch (FileNotFoundException ex) { _logger.ErrorFormat("{0} - '{1}'.", ex, ex.Message, ex.FileName); return(CommandResult.Error); } catch (Exception ex) { _logger.Error(ex); return(CommandResult.Error); } }
public CommandResult Execute() { try { _fileSystemMigrator.Migrate(); var assemblyPaths = Enumerable.Empty <string>(); var workingDirectory = _fileSystem.GetWorkingDirectory(_script); if (workingDirectory != null) { assemblyPaths = _assemblyResolver.GetAssemblyPaths(workingDirectory); } _composer.Compose(workingDirectory); _scriptExecutor.Initialize(assemblyPaths, _scriptPackResolver.GetPacks(), ScriptArgs); // HACK: This is a (dirty) fix for #1086. This might be a temporary solution until some further refactoring can be done. _scriptExecutor.ScriptEngine.CacheDirectory = Path.Combine(workingDirectory ?? _fileSystem.CurrentDirectory, _fileSystem.DllCacheFolder); var scriptResult = _scriptExecutor.Execute(_script, ScriptArgs); var commandResult = Inspect(scriptResult); _scriptExecutor.Terminate(); return(commandResult); } catch (Exception ex) { _logger.ErrorException("Error executing script '{0}'", ex, _script); return(CommandResult.Error); } }
public CommandResult Execute() { try { var assemblyPaths = Enumerable.Empty <string>(); var workingDirectory = _fileSystem.GetWorkingDirectory(_script); if (workingDirectory != null) { assemblyPaths = _assemblyResolver.GetAssemblyPaths(workingDirectory, _script); } _scriptExecutor.Initialize(assemblyPaths, _scriptPackResolver.GetPacks(), ScriptArgs); var result = _scriptExecutor.Execute(_script, ScriptArgs); _scriptExecutor.Terminate(); if (result == null) { return(CommandResult.Error); } if (result.CompileExceptionInfo != null) { _logger.Error(result.CompileExceptionInfo.SourceException.Message); _logger.Debug(result.CompileExceptionInfo.SourceException); return(CommandResult.Error); } if (result.ExecuteExceptionInfo != null) { _logger.Error(result.ExecuteExceptionInfo.SourceException); return(CommandResult.Error); } return(CommandResult.Success); } catch (FileNotFoundException fnfex) { _logger.ErrorFormat("{0} - {1}", fnfex.Message, fnfex.FileName); return(CommandResult.Error); } catch (Exception ex) { _logger.Error(ex.Message); return(CommandResult.Error); } }