public static ScriptCSSession Create(Cmdlet cmdlet) { ScriptCSSession session = null; var logger = new CurrentLogger(); using (logger.CreateActiveLoggerSession(new CmdletLogger(cmdlet))) { IScriptHostFactory factory = new ScriptHostFactory(); var engine = new RoslynScriptEngine(factory, logger); engine.BaseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var currentCmdletScriptPack = new CurrentCmdletScriptPack(); var scriptPackSession = new ScriptPackSession(new IScriptPack[] { currentCmdletScriptPack }); scriptPackSession.InitializePacks(); session = new ScriptCSSession( engine, scriptPackSession, currentCmdletScriptPack, logger ); } return session; }
protected override void BeginProcessing() { Script = "var pscmdlet = Require<CodeOwls.PowerShell.ScriptCS.CurrentCmdletContext>(); " + Script; var logger = new CmdletLogger( this ); IScriptHostFactory factory = new ScriptHostFactory(); _engine = new RoslynScriptEngine(factory, logger); _engine.BaseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }