Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installed .NET version is incompatible. #380

Open
Kamek437 opened this issue Jul 19, 2024 · 11 comments
Open

Installed .NET version is incompatible. #380

Kamek437 opened this issue Jul 19, 2024 · 11 comments

Comments

@Kamek437
Copy link

Upgraded to .Net 9.0.100-preview.6.24328.19 now when I start up sublime I get:

current_dotnet_version: 9.0.100-preview.6.24328.19
current_css_version: 4.6.2.0
current_syntaxer_version: 3.1.1.0
Runtime.min_compatible_dotnet_version: 6.0.0
Runtime.max_compatible_dotnet_version: 9.0.0
*************** CS-Script ******************
ERROR: 
Installed .NET version is incompatible.
@oleg-shilo
Copy link
Owner

The range of the .NET versions supporting CS-Script is higher than 6.0.0 - lower than 9.0.0
Though the plugin allows some flexibility you can simply point it to the alternative installation of cs-script of any version and then you will only be bound by the compatibility constraints between .NET and CS-Script.

Currently, the latest version of CS-Script is compiled against .NET 8.0. Thus it cannot fully function on .NET 9.
From the moment .NET 9 is released then CS-Script will be recompiled against it and immediately released.

Meaning, that we still have to wait. Or you can downgrade your preview version to .NET v8.*

@Kamek437
Copy link
Author

I have them both installed. 6-9sdk Why doesn't it switch for me to another version that allows it to function? The user should not have to deal with config script etc if they have a compatible version installed.

@oleg-shilo
Copy link
Owner

.NET SDK does not have a concept of switching.
Only a single version is active at the time.
If you execute dotnet --version it will show you which one.

The user should not have to deal with config script

There is nothing in cs-script configuration that you can use to achieve what you want. To load .NET9 compiled script (assembly) into .NET8 compiled script engine. What you are experiencing is a logical problem multiple .NET versions installed on the target system. I assist cs-script users by immediately releasing new cs-script build when a new version of .NET is released. But until it is available I have to wait.

I cannot exclude that there is a routing setting somewhere in config file that can force dotnet.exe to use different SDK version profile. But I have no idea how to achieve this.

Saying that, cs-script comes with one compiling engine that is independent on the version of .NTE . Roslyn.
Thus you can execute scripts even without SDK. You need to indicate the engine by supplying //css_ng roslyn as the first line in the script or supplying the CLI switch from the terminal:

css -ng:roslyn script.cs
#or
dotnet cscs.dll -ng:roslyn script.cs

Most likely it will work. Though Roslyn has some limitations. It can only work with static main and does not allow declaring namespaces:

This is the sample code that works:

//css_engine roslyn
using System;

public static void Main()
{
    Console.WriteLine("Hello World!");
}

Saying that I am willing to have a look at the exact problem and see if there is some work around (even though unlikely). So I am changing this issue to enhancement

@oleg-shilo
Copy link
Owner

I have done some investigation and it turns out that there is a relatively straightforward way of changing the target runtime for the script engine to the runtimes higher than the one that the engine was compiled for.
While I would consider this as a "if-I-have-to" workaround it's not a hack but a normal .NET configuration operation.

image

I will provision it in the next release distributable package. The dev experience will be something like this:

# set current runtime version for the script engine assembly
css -set-rt-self 

# set current runtime version for the given assembly
css -set-rt <assembly file> 

As for you, you don't have to wait for the release and you can manually update your latest CS-Script deployment to work on .NET9.0-Preview.
You will need to update C:\ProgramData\chocolatey\lib\cs-script\tools\cscs.runtimeconfig.json config content to the new dotnet:

image

If you are using CS-Script with some of IDEs that it is integrated with then you need to repeat the same for the syntaxer.exe file, which is an intellisense service for CS-Script scripts.

@oleg-shilo
Copy link
Owner

Not sure but it looks like you are using Sublime.
If it is the case, I can guide you through updating the Sublime config.

@Kamek437
Copy link
Author

Kamek437 commented Aug 6, 2024

Wow thanks! Yes I am using sublime. I made the changes to C:\ProgramData\chocolatey\lib\cs-script\tools\cscs.runtimeconfig.json, but I still get this:

Runtime.min_compatible_dotnet_version: 6.0.0
Runtime.max_compatible_dotnet_version: 9.0.0
*************** CS-Script ******************
ERROR: 
Installed .NET version is incompatible.

I can just roll back to .net 9.0, I just wanted to check out what was coming and all, it's not a biggy. If it's easy to make the other changes I think that other people coming along might benefit from it also but it might not be very popular to use the beta versions honestly.

@Kamek437
Copy link
Author

Kamek437 commented Aug 6, 2024

The above example script run and compiles fine, so I don't see any reason to bother you further. Thank you, you make an awesome product keep up the good work!

@oleg-shilo
Copy link
Owner

Runtime.max_compatible_dotnet_version: 9.0.0
Installed .NET version is incompatible.

Technically speaking it is an intended behaviour as the plugin is build for version 6.0.0(inclusive) - 9.0.0(exclusive).
But the message is misleading. I will replace it with something like this:

Compatible dotnet versionsrange: 
v6.0.0 - v9.0.0 (exclusive)
*************** CS-Script ******************
ERROR: 
Installed .NET version is incompatible.

@Kamek437
Copy link
Author

Kamek437 commented Aug 6, 2024

It seemed to still work fine for me, so maybe put "Defaulting to x.x version" or some such. That message makes it seem like it's broken.

@oleg-shilo
Copy link
Owner

correct. the message is misleading.
this should be better:

Compatible dotnet versions range: 
v6.0.0 - v9.0.0 (exclusive)
*************** CS-Script ******************
WARNING: 
The plugin may not work correctly with this .NET version.

Will do the change in the next release

@Kamek437
Copy link
Author

Kamek437 commented Aug 6, 2024

Thanks! Keep up the good work man.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants