beefarino / scriptcs-powershell-module

allows you to run arbitrary ScriptCS code from your PowerShell session
Other
24 stars 4 forks source link

ScriptCS session needs to live beyond the pipeline #1

Open beefarino opened 11 years ago

beefarino commented 11 years ago

At present the ScriptCS session does not live past the currently executing pipeline. Example:

> invoke-scriptcs 'var s = 0'; 
> invoke-scriptcs 's'
Invoke-ScriptCS : (1,78): error CS0103: The name 's' does not exist in the current context
At line:1 char:44
+ invoke-scriptcs 'var s=0;'; invoke-scriptcs <<<<  's'
+ CategoryInfo          : NotSpecified: (:) [Invoke-ScriptCS], CompilationErrorException

It would be nice if the ScriptCS session lived longer than this. I'm not sure if having a single ScriptCS session live for the length of the PowerShell session is the answer, or whether a New/Start/Exit/Get-ScriptCSSession cmdlet family (a la PSSession) is the better option:

> enter-scriptcsSession -name 'mysession'
> invoke-scriptcs -session mysession -script 'var s=0;'
> invoke-scriptcs 's'
0
>exit-scriptscSession mysession
> invoke-scriptcs 's'
Invoke-ScriptCS : (1,78): error CS0103: The name 's' does not exist in the current context
At line:1 char:44
+ invoke-scriptcs 'var s=0;'; invoke-scriptcs <<<<  's'
+ CategoryInfo          : NotSpecified: (:) [Invoke-ScriptCS], CompilationErrorException

I'm in tinker mode, and am open to input.