public async Task <TReturn> Execute <TReturn>(ExecuteLibraryCommandOptions options) { if (!File.Exists(options.LibraryPath)) { throw new Exception($"Couldn't find file '{options.LibraryPath}'"); } var absoluteFilePath = options.LibraryPath.GetRootedPath(); var compiler = GetScriptCompiler(!options.NoCache, _logFactory); var runner = new ScriptRunner(compiler, _logFactory, _scriptConsole); var result = await runner.Execute <TReturn>(absoluteFilePath, options.Arguments); return(result); }
public async Task <TReturn> Run <TReturn, THost>(ExecuteScriptCommandOptions options) { if (options.File.IsRemote) { return(await DownloadAndRunCode <TReturn>(options)); } var pathToLibrary = GetLibrary(options); var libraryOptions = new ExecuteLibraryCommandOptions(pathToLibrary, options.Arguments, options.NoCache) { #if NETCOREAPP AssemblyLoadContext = options.AssemblyLoadContext #endif }; return(await new ExecuteLibraryCommand(_scriptConsole, _logFactory).Execute <TReturn>(libraryOptions)); }
private async Task <TReturn> ExecuteLibrary <TReturn>(string pathToLibrary, string[] arguments, bool noCache) { var options = new ExecuteLibraryCommandOptions(pathToLibrary, arguments, noCache); return(await new ExecuteLibraryCommand(_scriptConsole, _logFactory).Execute <TReturn>(options)); }