dotnet-script 0.11 out – with inline Nuget support

Yesterday I released, thanks to the great help of Bernhard – version 0.11 of dotnet-script, the C# script runner for .NET Core.

It is the biggest release yet – with the highlight feature being the ability to use inline Nuget packages.

Here is the overview of what’s in there.

Inline Nuget packages

dotnet-script now supports inline #r directives for Nuget packages. This can be used in the following way:

It is the recommended way of referencing Nuget packages in the future.

project.json references are still supported but should be avoided. Remember, that when using them, you will need to make sure you use the version of dotnet CLI that is capable of restoring them (that is, non-csproj version of dotnet CLI). You can force a specific version of dotnet CLI in a given location using global.json file.

The new inline Nuget packages are also already supported on the tooling side by OmniSharp, which will recognize such reference correctly in order to provide intellisense and other language services. Make sure to get the latest preview of C# extension for Visual Studio Code. Because this feature is in preview in OmniSharp, you will then need to add the following entry to your omnisharp.json:

Stand alone execution support

Instead of having to install from Nuget as .NET CLI tool, you can now download a stand alone instance of dotnet-script as ZIP and use directly from the release page. Once the distro is unzipped, you can find the entry point files: dotnet-script.cmd and inside, which can be added to the PATH.

Once the dotnet-script folder is available the PATH, .NET CLI automatically recognizes it, and you can use the elegant dotnet script {filename.csx} command format.

Vastly improved debugging experience

Thanks to the move to Roslyn 2.3.1, debugging is much more dependable.
The debugger configuration is also much simplified. Here is the new launch.json configuration needed to debug:

Note that by using ${file} placeholder debugger automatically starts for the current file – no need to hardcode the name of the CSX in the launch.json.

You can also add a debugger break in your script and always attach to a paused script, since PDB symbols are now being emitted for each script execution.

Upgrade to NET Core App 1.1

The scripts now execute (and consume their inline Nuget dependencies) in the context of NET Core App 1.1.

Bug Fixes

  • correctly set the working directory path when resolving #r and #load directives. Additionally, fixed bugs related to #load and #r resolution when running scripts using relative path
  • improved handling of platform-specific dependencies
  • suppress bogus compiler warnings (i.e. CS1701)
  • do not lock file upon running the script
  • use CommandLineScriptGlobals instead of InteractiveScriptGlobals as the globals (“host”) type in the script execution context
  • correctly infer encoding for the source files when debugging
  • aligned internal script runner dependency versions and several other small build/development related fixes


If you want to contribute – please visit the Github repo! Thanks!

Share the post!