Skip to content

Error with NuGet using v4.8.9.0 on a server without .NET SDK #351

@UweKeim

Description

@UweKeim

On one of my production servers, I'm trying to migrate a script that runs successfully on CS-Script for .NET Framework to the latest version of CS-Script for .NET Core 8.

I do not have .NET SDK installed and would try everything to keep it this way.

My environment:

c:\>dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

This is my "test.cmd" batch file:

PUSHD 
CD /d %~dp0 

SET CSSCRIPT_ROOT=%~dp0\cs-script

"%~dp0\cs-script\cscs.exe" -ng:roslyn -config:set:LegacyNugetSupport=false

"%~dp0\cs-script\cscs.exe" -ng:roslyn -nuget:restore "%~dp0\test.cs"
"%~dp0\cs-script\cscs.exe" -ng:roslyn -dbg "%~dp0\test.cs" %*

POPD 
EXIT /B 0

And this is the test script "test.cs":

//css_nuget ZetaShortPaths

using System.Threading;

public static class Processor
{
	public static async Task Main(string[] args)
	{
	}
}

The package ZetaShortPaths is made by myself and I just released a version for .NET 8 today, some time ago.

I've also tried other NuGet packages like //css_nuget Morelinq but they all generate the same error (see below).

When running the "test.cmd" I get this output:

c:\Scheduler\Backup>c:\Scheduler\Backup\test.cmd

PUSHD

CD /d c:\Scheduler\Backup\

SET CSSCRIPT_ROOT=c:\Scheduler\Backup\\cs-script

"c:\Scheduler\Backup\\cs-script\cscs.exe" -ng:roslyn -config:set:LegacyNugetSupport=false
set: LegacyNugetSupport: False

"c:\Scheduler\Backup\\cs-script\cscs.exe" -ng:roslyn -nuget:restore "c:\Scheduler\Backup\\test.cs"
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'new' does not exist.
  * You intended to execute a .NET SDK command:
      No .NET SDKs were found.

Download a .NET SDK:
https://aka.ms/dotnet/download

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
Error: Specified file could not be compiled.

Could not find file 'C:\Users\Administrator\AppData\Local\Temp\csscript.core\nuget\1807e059-0f78-468f-8822-d270087a4456\1807e059-0f78-468f-8822-d270087a4456.csproj'.

"c:\Scheduler\Backup\\cs-script\cscs.exe" -ng:roslyn -dbg "c:\Scheduler\Backup\\test.cs"
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'new' does not exist.
  * You intended to execute a .NET SDK command:
      No .NET SDKs were found.

Download a .NET SDK:
https://aka.ms/dotnet/download

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
Error: Specified file could not be compiled.

Could not find file 'C:\Users\Administrator\AppData\Local\Temp\csscript.core\nuget\cf4997f6-d81c-4455-b2ef-9f50cd7ed48c\cf4997f6-d81c-4455-b2ef-9f50cd7ed48c.csproj'.

POPD

EXIT /B 0

c:\Scheduler\Backup>

The error I get above extracted reads:

Could not find file 'C:\Users\Administrator\AppData\Local\Temp\csscript.core\nuget\cf4997f6-d81c-4455-b2ef-9f50cd7ed48c\cf4997f6-d81c-4455-b2ef-9f50cd7ed48c.csproj'.

This sounds similar to issue #350.

In my scenario here, I cannot use dotnet tool install --global cs-script.cli since this would require the .NET SDK being installed, which I want to avoid.

Therefore I manually downloaded release v4.8.9.0 as 7z and extracted it.

I've also tried to set LegacyNugetSupport=true but this generates other error when running the script:

c:\Scheduler\Backup>c:\Scheduler\Backup\test.cmd

PUSHD

CD /d c:\Scheduler\Backup\

SET CSSCRIPT_ROOT=c:\Scheduler\Backup\\cs-script

"c:\Scheduler\Backup\\cs-script\cscs.exe" -ng:roslyn -config:set:LegacyNugetSupport=true
set: LegacyNugetSupport: True

"c:\Scheduler\Backup\\cs-script\cscs.exe" -ng:roslyn -nuget:restore "c:\Scheduler\Backup\\test.cs"
NuGet> Processing NuGet packages...

Error: Specified file could not be compiled.

> -----
A new NuGet package has been installed. If some of its components are not found you may need to restart the script again.
> -----

Cannot process NuGet package 'Morelinq'

"c:\Scheduler\Backup\\cs-script\cscs.exe" -ng:roslyn -dbg "c:\Scheduler\Backup\\test.cs"
NuGet> Processing NuGet packages...

Error: Specified file could not be compiled.

> -----
A new NuGet package has been installed. If some of its components are not found you may need to restart the script again.
> -----

Cannot process NuGet package 'Morelinq'

POPD

EXIT /B 0

c:\Scheduler\Backup>

My question

Any idea/hint on how to solve this and make CS-Script run without the .NET SDK being present?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions