public async Task <TReturn> Execute <TReturn>(ExecuteCodeCommandOptions options)
        {
            var sourceText = SourceText.From(options.Code);
            var context    = new ScriptContext(sourceText, options.WorkingDirectory ?? Directory.GetCurrentDirectory(), options.Arguments, null, options.OptimizationLevel, ScriptMode.Eval, options.PackageSources);
            var compiler   = GetScriptCompiler(!options.NoCache, _logFactory);
            var runner     = new ScriptRunner(compiler, _logFactory, _scriptConsole);

            return(await runner.Execute <TReturn>(context));
        }
Example #2
0
        private async Task <TReturn> DownloadAndRunCode <TReturn>(ExecuteScriptCommandOptions executeOptions)
        {
            var downloader = new ScriptDownloader();
            var code       = await downloader.Download(executeOptions.File.Path);

            var options = new ExecuteCodeCommandOptions(code, Directory.GetCurrentDirectory(), executeOptions.Arguments, executeOptions.OptimizationLevel, executeOptions.NoCache, executeOptions.PackageSources);

            return(await new ExecuteCodeCommand(_scriptConsole, _logFactory).Execute <TReturn>(options));
        }