cs-script: Does not run with .NET 8?

I’ve just updated my projects to .NET 8, pushed it to my GitLab instance which triggered a build pipeline that also uses cs-script. It runs inside a docker image mcr.microsoft.com/dotnet/sdk:latest.

Unfortunately this fails since the docker images was automatically upgraded to .NET 8.

Excerpt from the pipline log:

$ dotnet tool update --global cs-script.cli
Skipping NuGet package signature verification.
Tool 'cs-script.cli' was reinstalled with the latest stable version (version '4.8.7').
$ ~/.dotnet/tools/css -config:set:LegacyNugetSupport=false
You must install or update .NET to run this application.
App: /root/.dotnet/tools/css
Architecture: x[64](https://git.example.com/comp/repo/-/jobs/2978#L64)
Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)
.NET location: /usr/share/dotnet
The following frameworks were found:
  8.0.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Learn more:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0&arch=x64&rid=linux-x64&os=debian.12

My question:

Is it possible that you update cs-script to use .NET 8, please?

Or can I somehow tell cs-script to always use the latest available .NET version?

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 24 (14 by maintainers)

Most upvoted comments

Will publish it on nuget. Keep fingers crossed 🤞

Could be. BTW it is a problem in the code that you found. Restoring is done with the classic dotnet restore command and if the package is only available for net8 and your project is net7 then it will not .

Only two unintended cases of “net7” are still in code but only one (the first you mentioned) is engaged in the execution in your environment.

Let me fix it and send you the patch.

Great. We did well. That was a quick turnaround.

My local scripts seems to work again, mit CI scripts seem to work again. I’m closing this for now.

Героям Слава! My friend.

done, let nuget to index it and it will be available shortly.

I will take a break now and will check tmr. Let me know how it worked out.

Will do the rest of publishing tmr.

yep, it does

Just extracted the ZIP to “C:\Ablage\cs-script.win.v4.8.9.0”, and changed my “run.cmd” to this:

PUSHD 
CD /d %~dp0 

@REM --

"C:\Ablage\cs-script.win.v4.8.9.0\cscs.exe" -config:set:LegacyNugetSupport=false

"C:\Ablage\cs-script.win.v4.8.9.0\cscs.exe" -nuget:restore "%~dp0\run.cs"

@REM --

POPD
EXIT /B 0

The output looks like this:

c:\Ablage>c:\Ablage\run.cmd

PUSHD

CD /d c:\Ablage\

"C:\Ablage\cs-script.win.v4.8.9.0\cscs.exe" -config:set:LegacyNugetSupport=false
set: LegacyNugetSupport: False

"C:\Ablage\cs-script.win.v4.8.9.0\cscs.exe" -nuget:restore "c:\Ablage\\run.cs"
Restoring packages...
Mapping packages to assemblies...
Compile: OK

POPD

EXIT /B 0

c:\Ablage>

Seems to indicate it is working, right?

Here we go.

Just place the release manually on your system and test it to see if it addresses the issue.

cs-script.win.v4.8.9.0.zip

Yes publishing dotnet-tool is quick. I only want to ensure it works before I do it again. I am working on it right now. There is a good chance that net 7 is the leftover that makes that difference.

Thank you very much, Oleg!

I’ve assembled a small test script. The error seems to only occur with NuGet packages coming from our local NuGet server.

I’ll send you an example script via email as it includes sensitive data to add the nuget source.

My CI scripts do run again. Awesome! Thank you very much for your fast help!

Great. Not a problem. BTW I found that the problem was caused by the default dotnet project template (used when executing scripts with the dotnet engine) was always targeting .NET 7. It was a mistake in the code and it ic corrected with the latest release. Executing scripts with csc engine was immune to this problem. BTW in my environment I had no problems because my config is set to -ng:csc.

. . .

Also wanted to thank you for your continuous support. Much appreciated.

This should get you going

Done. https://github.com/oleg-shilo/cs-script/releases/tag/v4.8.8.0

Please give me some time to prepare distros (choco and winget) and I will mark the release as “production”. At the moment it is prerelease.

Note: DodtNdet.tool is already published.

LOL, just got the update VS update

Hi Uwe,

I am not sure what exactly causing the problem there, but it looks like you cannot even run css. I just have installed .NET 8 over my .NET 7. And it seems like they still can coincide gracefully:

image

Recompilation of the script engine for .NET 8 is a valid approach but at the moment VS v17.8 supporting .NET 8 is not available and VS v17.7 generates the warnings so I am a little cautious.

image

I will build the new release as a preview so you can test it.

If it works well then I will publish it as a proper release on nuget.tools. BTW, I am very close to publishing it on WinGet as well