run single *.cs script from command line

I found another solution on Scott Hanselman’s blog:

https://www.hanselman.com/blog/CAndNETCoreScriptingWithTheDotnetscriptGlobalTool.aspx

It relies on a .NET CLI tool called dotnet-script, you can find its repository below:

https://github.com/filipw/dotnet-script

To use, it, first install it using dotnet tool install -g dotnet-script

Then you can run dotnet script and use it as a REPL or run dotnet script file.csx to run a file.

To include a NuGet package reference, use #r "nuget: AutoMapper, 6.1.0".

Leave a Comment