oleg-shilo / cs-script.vscode

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

.Net Framework 4.8 support #37

Open gw-ubunye opened 1 year ago

gw-ubunye commented 1 year ago

Does this extension support .Net Framework 4.8? If so, what are the steps to do so?

oleg-shilo commented 1 year ago

Yes, it is possible even though not directly. The extension is designed to support .NET Core family runtimes and is distributed with the script engine CS-Script targeting exactly that runtime. All services like auto-completion, go-to-definition et. are all targeting this runtimes.

Though you can change the execution engine, specifically, you can download the .NET Framework edition of CS-Script and point VSCode to it.

Thus your intellisense (syntax services) will be running in VSCode on .NET Core, which is fine. Your script type model is the same regardless of the runtime model. But the script execution will be done under .NET Framework.

You can download .NETFramework CS-SCript from here.

And you will need to set VSCode extension Cscs_exe value to the location of the downloaded and extracted cscs.exe here:

image

gw-ubunye commented 1 year ago

Thank you for the reply, Oleg. We are not able to get this working though. When setting the Cscs path to, "C:\Binaries_for_DOTNET_4.8\cscs.exe" in my case, nothing happens when running a script. When you try to run it a second time, it pops up with a "CS-Script is busy".

I have the .Net framework 4.8 SDK installed.

oleg-shilo commented 1 year ago

can you please try to execute the script from the terminal:

"C:\Binaries_for_DOTNET_4.8\cscs.exe" <path to your script>

This is to check that the problem of cscs.exe handing is caused by some execution runtime problem the extension does not catch.

gw-ubunye commented 1 year ago

I can execute the script without issue using the command line.

oleg-shilo commented 1 year ago

Then it means that it only hangs when you execute it via VSCode launcher (F%). Thus I suggest you edit the script in VSCode but execute it in the terminal.

image

I have dug a bit deeper and indeed setting Cscs path will not help as the extension is still treating the assembly you specified as a .NET Core assembly and tries execute it via dotnet launcher:

dotnet <cscs.exe> <your script>

And dotnet.exe cannot recover from an attempt to load .NET Framework assembly. You can probably automate it with some extensions (e.g. Command launcher).

gw-ubunye commented 1 year ago

Hmm. Ok. How does this impact the debug experience though?

I also noticed that code completion does not work properly.

To be clear, and just to make sure I don't have environmental issues, what I need are:

  1. .Net Framework 4.8 SDK
  2. VS Code plugins, CS-Script, C# and Mono Debug
  3. Binaries for .Net 4.8 only, i.e. not the full suite

What I want to be able to do, is to write and debug scripts which reference 32bit, .Net Framework 4.8 assemblies. With syntax highlighting and code completion.

oleg-shilo commented 1 year ago

Judging from your last message, I misunderstood your requests and assumed you only want to execute your script under .NET but the rest of VSCode experience is less important. So let me clarify all that.

The current version of the extension targets .NET Core. This applies to all aspects Intellisense, debugging and execution.

Thus if you develop .NET Fx code then intellisense can be impacted, debugging and execution will just fail.

Where does it leave you?

You can install an older version of the extension that targets .NET Framework natively: cs-script-1.5.12.vsix (Mar 2020). But since it is 4 years old it may not work as it did at the time.

I personally use Sublime Text with cs-script extension to edit my all scripts against .NET Core runtime. But for the execution I use a specific engine (.NET Framework or .NET Core).

And for debugging, I simply execute the script with the //x argument at the end of the command line:

cscs <my script> //x

This will trigger a deliberate assertion in the engine assembly and you will be prompted to attach the system debugger.
Confirm it, then F11 and you are in. Debugging with the full power of VS

gw-ubunye commented 1 year ago

Understood. Thank you for taking the time to clarify it all.

oleg-shilo commented 1 year ago

You can also use Notepad++ the same way as Sublime Text: image

But debugging.NET Framework is still only available under VS.