oleg-shilo / cs-script.vscode

VSCode extension for CS-Script
MIT License
37 stars 7 forks source link

Execute CS scripts on double-click #14

Closed Nicolas01 closed 5 years ago

Nicolas01 commented 5 years ago

In explorer I associated the *.csx files to %APPDATA%\Code\User\cs-script.user\cscs.exe
But when I double-click on a *.csx file a console is displayed but disappears immediately.
Do you know how could I obtain the following behavior: double-click on a *.csx file opens a console, executes my cs script in it (allowing input read) and stays alive if I put a Console.ReadKey() in my cs script?

oleg-shilo commented 5 years ago

You can do it by passing -wait argument:

cscs -wait "%1"

You can also have a right-click "Debug" menu action:

cscs "%1" //x

On Windows it will trigger a startup breakpoint/assertion and prompt user to attach any of the system debuggers (e.g. Visual Studio).

For the all arguments (and syntax) info/help use cscs itself:

cscs -cmd
cscs -syntax
or for the individual arg
cscs -wait ?

You may also want to pull CS-Script on your system from Choco:

choco install cs-script

And for Linux see this wiki: https://github.com/oleg-shilo/cs-script/wiki/CS-Script-on-Linux

Nicolas01 commented 5 years ago

Thanks the -wait argument works like a charm.
I associated my *.csx files to cscs.exe then I edited the HKCU\Software\Classes\Applications\cscs.exe\shell\open\command key:
(Default) = "C:\Users\???\AppData\Roaming\Code\User\cs-script.user\cscs.exe" -wait "%1"