.NET Core script
From Logic Wiki
Contents
Installation
To install dotnet-script:
dotnet tool install -g dotnet-script
Creating a hello world sample
copy con helloworld.csx
Console.WriteLine("Hello world!");
^Z
Linux
If you were doing this in Linux or OSX you'll need to include a "shebang" as the first line of the script. This is a standard thing for scripting files like bash, python, etc.
#!/usr/bin/env dotnet-script
Console.WriteLine("Hello world");
This lets the operating system know what scripting engine handles this file.
Nuget
If you you want to refer to a NuGet package within a script (*.csx) file, you'll use the Roslyn #r syntax:
#r "nuget: AutoMapper, 6.1.0"
Console.WriteLine("whatever);
REPL
You can use it as a REPL! (Read Evaluate Print Loop)
C:\Users\scott\Desktop\scriptie>dotnet script > 2+2 4 > var x = "scott hanselman"; > x.ToUpper() "SCOTT HANSELMAN"
See Also https://www.hanselman.com/blog/CAndNETCoreScriptingWithTheDotnetscriptGlobalTool.aspx