oleg-shilo / cs-script

C# scripting platform
http://www.cs-script.net
MIT License
1.6k stars 235 forks source link

Could not find a part of the path #381

Open 344089386 opened 1 month ago

344089386 commented 1 month ago

Occasional: Could not find a part of the path 'C:\Users\semitech\AppData\Local\Temp\CSSCRIPT\36880.d03ac708-8d9d-4062-9763-503deb6a1852.tmp.cs'.

What's going on, please

oleg-shilo commented 1 month ago

This is a temp file containing a complete C# code created from your C# code fragment that is a script. The script creates this file and then passes it to the C# compiler that is configured on your system. So something deleting or locking this file. Can it be antivirus?

If it becomes unusable you can try to change the compiler engine with the -ng switch. Check all available options with css -ng ?

But from my memory

css -ng:dotnet sample.cs
css -ng:csc sample.cs
css -ng:csc-inproc sample.cs
css -ng:roslyn-inproc sample.cs
css -ng:roslyn sample.cs
344089386 commented 1 month ago

I haven't used 'css -ng :dotnet', can you give me a detailed link? @oleg-shilo

oleg-shilo commented 1 month ago

You just execute css -ng ? and it will print the CLI usage of this switch. Alternatively, you can specify the same switch directly from the script code. IE:

//css_ng dotnet

<your script code>

CS-Script always converts C# script into an assembly and executes it.

What this switch does it tells CS-Script which C# compiler to use for building the assembly.

  1. dotnet - means prepare a C# project on-fly, build the assembly and destroy the project (part of .NET SDK)
  2. csc - means compile assembly from C# source file with csc.exe C# compiler (part of .NET SDK) as external process
  3. roslyn - means compile assembly from C# code with .NET Roslyn Compiler (compiler-as-service nuget package)