{"id":13490488,"url":"https://github.com/dotnet-script/dotnet-script","last_synced_at":"2025-05-14T22:02:32.387Z","repository":{"id":38450907,"uuid":"70060215","full_name":"dotnet-script/dotnet-script","owner":"dotnet-script","description":"Run C# scripts from the .NET CLI.","archived":false,"fork":false,"pushed_at":"2024-11-13T18:59:28.000Z","size":8252,"stargazers_count":2876,"open_issues_count":125,"forks_count":175,"subscribers_count":57,"default_branch":"master","last_synced_at":"2025-05-07T21:12:59.029Z","etag":null,"topics":["csharp-script","csi","csx","dotnet-script","roslyn"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotnet-script.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-05T12:54:55.000Z","updated_at":"2025-05-04T07:31:05.000Z","dependencies_parsed_at":"2024-01-05T20:52:42.006Z","dependency_job_id":"bcac0356-12ab-45ee-95d1-b92d87db61bf","html_url":"https://github.com/dotnet-script/dotnet-script","commit_stats":{"total_commits":1071,"total_committers":39,"mean_commits":27.46153846153846,"dds":0.5266106442577031,"last_synced_commit":"116931403e0ee07890e9e0c89689b1a2f58fad32"},"previous_names":["filipw/dotnet-script"],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-script%2Fdotnet-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-script%2Fdotnet-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-script%2Fdotnet-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-script%2Fdotnet-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotnet-script","download_url":"https://codeload.github.com/dotnet-script/dotnet-script/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235685,"owners_count":22036962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp-script","csi","csx","dotnet-script","roslyn"],"created_at":"2024-07-31T19:00:47.337Z","updated_at":"2025-05-14T22:02:32.300Z","avatar_url":"https://github.com/dotnet-script.png","language":"C#","funding_links":[],"categories":["C#","C# #","C\\#"],"sub_categories":[],"readme":"# dotnet script\n\nRun C# scripts from the .NET CLI, define NuGet packages inline and edit/debug them in VS Code - all of that with full language services support from OmniSharp.\n\n## Build status\n\n[![Build Status](https://bernhardrichter.visualstudio.com/dotnet-script/_apis/build/status/filipw.dotnet-script?branchName=master)](https://bernhardrichter.visualstudio.com/dotnet-script/_build/latest?definitionId=4\u0026branchName=master)\n\n## NuGet Packages\n\n| Name                                  | Version                                                                                                                                                             | Framework(s)                       |\n| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |\n| `dotnet-script` (global tool)         | [![Nuget](http://img.shields.io/nuget/v/dotnet-script.svg?maxAge=10800)](https://www.nuget.org/packages/dotnet-script/)                                             | `net8.0`,`net9.0`                  |\n| `Dotnet.Script` (CLI as Nuget)        | [![Nuget](http://img.shields.io/nuget/v/dotnet.script.svg?maxAge=10800)](https://www.nuget.org/packages/dotnet.script/)                                             | `net8.0`,`net9.0`                  |\n| `Dotnet.Script.Core`                  | [![Nuget](http://img.shields.io/nuget/v/Dotnet.Script.Core.svg?maxAge=10800)](https://www.nuget.org/packages/Dotnet.Script.Core/)                                   | `net8.0`,`net9.0`,`netstandard2.0` |\n| `Dotnet.Script.DependencyModel`       | [![Nuget](http://img.shields.io/nuget/v/Dotnet.Script.DependencyModel.svg?maxAge=10800)](https://www.nuget.org/packages/Dotnet.Script.DependencyModel/)             | `netstandard2.0`                   |\n| `Dotnet.Script.DependencyModel.Nuget` | [![Nuget](http://img.shields.io/nuget/v/Dotnet.Script.DependencyModel.Nuget.svg?maxAge=10800)](https://www.nuget.org/packages/Dotnet.Script.DependencyModel.Nuget/) | `netstandard2.0`                   |\n\n## Installing\n\n### Prerequisites\n\nThe only thing we need to install is [.NET 8.0 or .NET 9.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet).\n\n[Note](https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#manual-install):\n\u003e If you install the .NET SDK to a non-default location, you need to set the environment variable `DOTNET_ROOT` to the directory that contains the dotnet executable\n\n### .NET Core Global Tool\n\n.NET Core 2.1 introduced the concept of global tools meaning that you can install `dotnet-script` using nothing but the .NET CLI.\n\n```shell\ndotnet tool install -g dotnet-script\n\nYou can invoke the tool using the following command: dotnet-script\nTool 'dotnet-script' (version '0.22.0') was successfully installed.\n```\n\nThe advantage of this approach is that you can use the same command for installation across all platforms.\n.NET Core SDK also supports viewing a list of installed tools and their uninstallation.\n\n```shell\ndotnet tool list -g\n\nPackage Id         Version      Commands\n---------------------------------------------\ndotnet-script      0.22.0       dotnet-script\n```\n\n```shell\ndotnet tool uninstall dotnet-script -g\n\nTool 'dotnet-script' (version '0.22.0') was successfully uninstalled.\n```\n\n### Windows\n\nPowerShell script for installation.\n\n```powershell\n(new-object Net.WebClient).DownloadString(\"https://raw.githubusercontent.com/dotnet-script/dotnet-script/master/install/install.ps1\") | iex\n```\n\n### Linux and Mac\n\n```shell\ncurl -s https://raw.githubusercontent.com/dotnet-script/dotnet-script/master/install/install.sh | bash\n```\n\nIf permission is denied we can try with `sudo`\n\n```shell\ncurl -s https://raw.githubusercontent.com/dotnet-script/dotnet-script/master/install/install.sh | sudo bash\n```\n\n### Docker\n\nA Dockerfile for running dotnet-script in a Linux container is available. Build:\n\n```shell\ncd build\ndocker build -t dotnet-script -f Dockerfile ..\n```\n\nAnd run:\n\n```shell\ndocker run -it dotnet-script --version\n```\n\n### Github\n\nYou can manually download all the releases in `zip` format from the [GitHub releases page](https://github.com/dotnet-script/dotnet-script/releases).\n\n## Usage\n\nOur typical `helloworld.csx` might look like this:\n\n```cs\nConsole.WriteLine(\"Hello world!\");\n```\n\nThat is all it takes and we can execute the script. Args are accessible via the global Args array.\n\n```\ndotnet script helloworld.csx\n```\n\nThe following namespaces are available in the script implicitly and do not need to be imported explicitly:\n\n - System\n - System.IO\n - System.Collections.Generic\n - System.Console\n - System.Diagnostics\n - System.Dynamic\n - System.Linq\n - System.Linq.Expressions\n - System.Text\n - System.Threading.Tasks\n\n### Scaffolding\n\nSimply create a folder somewhere on your system and issue the following command.\n\n```shell\ndotnet script init\n```\n\nThis will create `main.csx` along with the launch configuration needed to debug the script in VS Code.\n\n```shell\n.\n├── .vscode\n│   └── launch.json\n├── main.csx\n└── omnisharp.json\n```\n\nWe can also initialize a folder using a custom filename.\n\n```shell\ndotnet script init custom.csx\n```\n\nInstead of `main.csx` which is the default, we now have a file named `custom.csx`.\n\n```shell\n.\n├── .vscode\n│   └── launch.json\n├── custom.csx\n└── omnisharp.json\n```\n\n\u003e Note: Executing `dotnet script init` inside a folder that already contains one or more script files will not create the `main.csx` file.\n\n### Running scripts\n\nYou can execute your script using **dotnet script** or **dotnet-script**. \n\n```bash\ndotnet script foo.csx\ndotnet-script foo.csx\n```\n\nOn OSX/Linux, scripts can be executed directly from a shell as if they were executables.\n\n```bash\nfoo.csx arg1 arg2 arg3\n```\n\n\u003e OSX/Linux\n\u003e\n\u003e Just like all scripts, on OSX/Linux you need to have a `#!` and mark the file as executable via **chmod +x foo.csx**.\n\u003e If you use **dotnet script init** to create your csx it will automatically have the `#!` directive and be marked as\n\u003e executable.\n\nThe OSX/Linux shebang directive should be **#!/usr/bin/env dotnet-script**\n\n```cs\n#!/usr/bin/env dotnet-script\nConsole.WriteLine(\"Hello world\");\n```\n\nOn Windows, you can run `dotnet script register` to achieve a similar behaviour. This registers dotnet-script in the Windows registry as the tool to process .csx files.\n\nYou can pass arguments to control your script execution more.\n\n```bash\nfoo.csx arg1 arg2 arg3\ndotnet script foo.csx -- arg1 arg2 arg3\ndotnet-script foo.csx -- arg1 arg2 arg3\n```\n\n#### Passing arguments to scripts\n\nAll arguments after `--` are passed to the script in the following way:\n\n```shell\ndotnet script foo.csx -- arg1 arg2 arg3\n```\n\nThen you can access the arguments in the script context using the global `Args` collection:\n\n```c#\nforeach (var arg in Args)\n{\n    Console.WriteLine(arg);\n}\n```\n\nAll arguments before `--` are processed by `dotnet script`. For example, the following command-line\n\n```shell\ndotnet script -d foo.csx -- -d\n```\n\nwill pass the `-d` before `--` to `dotnet script` and enable the debug mode whereas the `-d` after `--` is passed to script for its own interpretation of the argument.\n\n### NuGet Packages\n\n`dotnet script` has built-in support for referencing NuGet packages directly from within the script.\n\n```c#\n#r \"nuget: AutoMapper, 6.1.0\"\n```\n\n![package](https://user-images.githubusercontent.com/1034073/30176983-98a6b85e-9404-11e7-8855-4ae65a20d6b1.gif)\n\n\u003e Note: Omnisharp needs to be restarted after adding a new package reference\n\n#### Package Sources\n\nWe can define package sources using a `NuGet.Config` file in the script root folder. In addition to being used during execution of the script, it will also be used by `OmniSharp` that provides language services for packages resolved from these package sources.\n\nAs an alternative to maintaining a local `NuGet.Config` file we can define these package sources globally either at the user level or at the computer level as described in [Configuring NuGet Behaviour](https://docs.microsoft.com/en-us/nuget/reference/nuget-config-file)\n\nIt is also possible to specify packages sources when executing the script.\n\n```shell\ndotnet script foo.csx -s https://SomePackageSource\n```\n\nMultiple packages sources can be specified like this:\n\n```shell\ndotnet script foo.csx -s https://SomePackageSource -s https://AnotherPackageSource\n```\n\n### Creating DLLs or Exes from a CSX file\n\nDotnet-Script can create a standalone executable or DLL for your script.\n\n| Switch | Long switch                     | description                                                                                                         |\n| ------ | ------------------------------- | ------------------------------------------------------------------------------------------------------------------- |\n| -o     | --output                        | Directory where the published executable should be placed. Defaults to a 'publish' folder in the current directory. |\n| -n     | --name                          | The name for the generated DLL (executable not supported at this time). Defaults to the name of the script.         |\n|        | --dll                           | Publish to a .dll instead of an executable.                                                                         |\n| -c     | --configuration \u003cconfiguration\u003e | Configuration to use for publishing the script [Release/Debug]. Default is \"Debug\"                                  |\n| -d     | --debug                         | Enables debug output.                                                                                               |\n| -r     | --runtime                       | The runtime used when publishing the self contained executable. Defaults to your current runtime.                   |\n\nThe executable you can run directly independent of dotnet install, while the DLL can be run using the dotnet CLI like this:\n\n```shell\ndotnet script exec {path_to_dll} -- arg1 arg2\n```\n\n### Caching\n\nWe provide two types of caching, the `dependency cache` and the `execution cache` which is explained in detail below. In order for any of these caches to be enabled, it is required that all NuGet package references are specified using an exact version number. The reason for this constraint is that we need to make sure that we don't execute a script with a stale dependency graph.\n\n#### Dependency Cache\n\nIn order to resolve the dependencies for a script, a `dotnet restore` is executed under the hood to produce a `project.assets.json` file from which we can figure out all the dependencies we need to add to the compilation.\nThis is an out-of-process operation and represents a significant overhead to the script execution. So this cache works by looking at all the dependencies specified in the script(s) either in the form of NuGet package references or assembly file references. If these dependencies matches the dependencies from the last script execution, we skip the restore and read the dependencies from the already generated `project.assets.json` file. If any of the dependencies has changed, we must restore again to obtain the new dependency graph.\n\n#### Execution cache\n\nIn order to execute a script it needs to be compiled first and since that is a CPU and time consuming operation, we make sure that we only compile when the source code has changed. This works by creating a SHA256 hash from all the script files involved in the execution. This hash is written to a temporary location along with the DLL that represents the result of the script compilation. When a script is executed the hash is computed and compared with the hash from the previous compilation. If they match there is no need to recompile and we run from the already compiled DLL. If the hashes don't match, the cache is invalidated and we recompile.\n\n\u003e You can override this automatic caching by passing **--no-cache** flag, which will bypass both caches and cause dependency resolution and script compilation to happen every time we execute the script.\n\n#### Cache Location\n\nThe temporary location used for caches is a sub-directory named `dotnet-script` under (in order of priority):\n\n1. The path specified for the value of the environment variable named `DOTNET_SCRIPT_CACHE_LOCATION`, if defined and value is not empty.\n2. Linux distributions only: `$XDG_CACHE_HOME` if defined otherwise `$HOME/.cache`\n3. macOS only: `~/Library/Caches`\n4. The value returned by [`Path.GetTempPath`](https://docs.microsoft.com/en-us/dotnet/api/system.io.path.gettemppath) for the platform.\n\n###\n\n### Debugging\n\nThe days of debugging scripts using `Console.WriteLine` are over. One major feature of `dotnet script` is the ability to debug scripts directly in VS Code. Just set a breakpoint anywhere in your script file(s) and hit F5(start debugging)\n\n![debug](https://user-images.githubusercontent.com/1034073/30173509-2f31596c-93f8-11e7-9124-ca884cf6564e.gif)\n\n### Script Packages\n\nScript packages are a way of organizing reusable scripts into NuGet packages that can be consumed by other scripts. This means that we now can leverage scripting infrastructure without the need for any kind of bootstrapping.\n\n#### Creating a script package\n\nA script package is just a regular NuGet package that contains script files inside the `content` or `contentFiles` folder.\n\nThe following example shows how the scripts are laid out inside the NuGet package according to the [standard convention](https://docs.microsoft.com/en-us/nuget/schema/nuspec#including-content-files) .\n\n```shell\n└── contentFiles\n    └── csx\n        └── netstandard2.0\n            └── main.csx\n```\n\nThis example contains just the `main.csx` file in the root folder, but packages may have multiple script files either in the root folder or in subfolders below the root folder.\n\nWhen loading a script package we will look for an entry point script to be loaded. This entry point script is identified by one of the following.\n\n- A script called `main.csx` in the root folder\n- A single script file in the root folder\n\nIf the entry point script cannot be determined, we will simply load all the scripts files in the package.\n\n\u003e The advantage with using an entry point script is that we can control loading other scripts from the package.\n\n#### Consuming a script package\n\nTo consume a script package all we need to do specify the NuGet package in the `#load`directive.\n\nThe following example loads the [simple-targets](https://www.nuget.org/packages/simple-targets-csx) package that contains script files to be included in our script.\n\n```C#\n#load \"nuget:simple-targets-csx, 6.0.0\"\n\nusing static SimpleTargets;\nvar targets = new TargetDictionary();\n\ntargets.Add(\"default\", () =\u003e Console.WriteLine(\"Hello, world!\"));\n\nRun(Args, targets);\n```\n\n\u003e Note: Debugging also works for script packages so that we can easily step into the scripts that are brought in using the `#load` directive.\n\n### Remote Scripts\n\nScripts don't actually have to exist locally on the machine. We can also execute scripts that are made available on an `http(s)` endpoint.\n\nThis means that we can create a Gist on Github and execute it just by providing the URL to the Gist.\n\nThis [Gist](https://gist.githubusercontent.com/seesharper/5d6859509ea8364a1fdf66bbf5b7923d/raw/0a32bac2c3ea807f9379a38e251d93e39c8131cb/HelloWorld.csx) contains a script that prints out \"Hello World\"\n\nWe can execute the script like this\n\n```shell\ndotnet script https://gist.githubusercontent.com/seesharper/5d6859509ea8364a1fdf66bbf5b7923d/raw/0a32bac2c3ea807f9379a38e251d93e39c8131cb/HelloWorld.csx\n```\n\nThat is a pretty long URL, so why don't make it a [TinyURL](https://tinyurl.com/) like this:\n\n```shell\ndotnet script https://tinyurl.com/y8cda9zt\n```\n\n### Script Location\n\nA pretty common scenario is that we have logic that is relative to the script path. We don't want to require the user to be in a certain directory for these paths to resolve correctly so here is how to provide the script path and the script folder regardless of the current working directory.\n\n```c#\npublic static string GetScriptPath([CallerFilePath] string path = null) =\u003e path;\npublic static string GetScriptFolder([CallerFilePath] string path = null) =\u003e Path.GetDirectoryName(path);\n```\n\n\u003e Tip: Put these methods as top level methods in a separate script file and `#load` that file wherever access to the script path and/or folder is needed.\n\n## REPL\n\nThis release contains a C# REPL (Read-Evaluate-Print-Loop). The REPL mode (\"interactive mode\") is started by executing `dotnet-script` without any arguments.\n\nThe interactive mode allows you to supply individual C# code blocks and have them executed as soon as you press \u003ckbd\u003eEnter\u003c/kbd\u003e. The REPL is configured with the same default set of assembly references and using statements as regular CSX script execution.\n\n### Basic usage\n\nOnce `dotnet-script` starts you will see a prompt for input. You can start typing C# code there.\n\n```\n~$ dotnet script\n\u003e var x = 1;\n\u003e x+x\n2\n```\n\nIf you submit an unterminated expression into the REPL (no `;` at the end), it will be evaluated and the result will be serialized using a formatter and printed in the output. This is a bit more interesting than just calling `ToString()` on the object, because it attempts to capture the actual structure of the object. For example:\n\n```\n~$ dotnet script\n\u003e var x = new List\u003cstring\u003e();\n\u003e x.Add(\"foo\");\n\u003e x\nList\u003cstring\u003e(1) { \"foo\" }\n\u003e x.Add(\"bar\");\n\u003e x\nList\u003cstring\u003e(2) { \"foo\", \"bar\" }\n\u003e\n```\n\n### Inline Nuget packages\n\nREPL also supports inline Nuget packages - meaning the Nuget packages can be installed into the REPL from _within the REPL_. This is done via our `#r` and `#load` from Nuget support and uses identical syntax.\n\n```\n~$ dotnet script\n\u003e #r \"nuget: Automapper, 6.1.1\"\n\u003e using AutoMapper;\n\u003e typeof(MapperConfiguration)\n[AutoMapper.MapperConfiguration]\n\u003e #load \"nuget: simple-targets-csx, 6.0.0\";\n\u003e using static SimpleTargets;\n\u003e typeof(TargetDictionary)\n[Submission#0+SimpleTargets+TargetDictionary]\n```\n\n### Multiline mode\n\nUsing Roslyn syntax parsing, we also support multiline REPL mode. This means that if you have an uncompleted code block and press \u003ckbd\u003eEnter\u003c/kbd\u003e, we will automatically enter the multiline mode. The mode is indicated by the `*` character. This is particularly useful for declaring classes and other more complex constructs.\n\n```\n~$ dotnet script\n\u003e class Foo {\n* public string Bar {get; set;}\n* }\n\u003e var foo = new Foo();\n```\n\n### REPL commands\n\nAside from the regular C# script code, you can invoke the following commands (directives) from within the REPL:\n\n| Command  | Description                                                  |\n| -------- | ------------------------------------------------------------ |\n| `#load`  | Load a script into the REPL (same as `#load` usage in CSX)   |\n| `#r`     | Load an assembly into the REPL (same as `#r` usage in CSX)   |\n| `#reset` | Reset the REPL back to initial state (without restarting it) |\n| `#cls`   | Clear the console screen without resetting the REPL state    |\n| `#exit`  | Exits the REPL                                               |\n\n### Seeding REPL with a script\n\nYou can execute a CSX script and, at the end of it, drop yourself into the context of the REPL. This way, the REPL becomes \"seeded\" with your code - all the classes, methods or variables are available in the REPL context. This is achieved by running a script with an `-i` flag.\n\nFor example, given the following CSX script:\n\n```csharp\nvar msg = \"Hello World\";\nConsole.WriteLine(msg);\n```\n\nWhen you run this with the `-i` flag, `Hello World` is printed, REPL starts and `msg` variable is available in the REPL context.\n\n```\n~$ dotnet script foo.csx -i\nHello World\n\u003e\n```\n\nYou can also seed the REPL from inside the REPL - at any point - by invoking a `#load` directive pointed at a specific file. For example:\n\n```\n~$ dotnet script\n\u003e #load \"foo.csx\"\nHello World\n\u003e\n```\n\n## Piping\n\nThe following example shows how we can pipe data in and out of a script.\n\nThe `UpperCase.csx` script simply converts the standard input to upper case and writes it back out to standard output.\n\n```csharp\nusing (var streamReader = new StreamReader(Console.OpenStandardInput()))\n{\n    Write(streamReader.ReadToEnd().ToUpper());\n}\n```\n\nWe can now simply pipe the output from one command into our script like this.\n\n```shell\necho \"This is some text\" | dotnet script UpperCase.csx\nTHIS IS SOME TEXT\n```\n\n### Debugging\n\nThe first thing we need to do add the following to the `launch.config` file that allows VS Code to debug a running process.\n\n```JSON\n{\n    \"name\": \".NET Core Attach\",\n    \"type\": \"coreclr\",\n    \"request\": \"attach\",\n    \"processId\": \"${command:pickProcess}\"\n}\n```\n\nTo debug this script we need a way to attach the debugger in VS Code and the simplest thing we can do here is to wait for the debugger to attach by adding this method somewhere.\n\n```c#\npublic static void WaitForDebugger()\n{\n    Console.WriteLine(\"Attach Debugger (VS Code)\");\n    while(!Debugger.IsAttached)\n    {\n    }\n}\n```\n\nTo debug the script when executing it from the command line we can do something like\n\n```c#\nWaitForDebugger();\nusing (var streamReader = new StreamReader(Console.OpenStandardInput()))\n{\n    Write(streamReader.ReadToEnd().ToUpper()); // \u003c- SET BREAKPOINT HERE\n}\n```\n\nNow when we run the script from the command line we will get\n\n```shell\n$ echo \"This is some text\" | dotnet script UpperCase.csx\nAttach Debugger (VS Code)\n```\n\nThis now gives us a chance to attach the debugger before stepping into the script and from VS Code, select the `.NET Core Attach` debugger and pick the process that represents the executing script.\n\nOnce that is done we should see our breakpoint being hit.\n\n## Configuration(Debug/Release)\n\nBy default, scripts will be compiled using the `debug` configuration. This is to ensure that we can debug a script in VS Code as well as attaching a debugger for long running scripts.\n\nThere are however situations where we might need to execute a script that is compiled with the `release` configuration. For instance, running benchmarks using [BenchmarkDotNet](http://benchmarkdotnet.org/) is not possible unless the script is compiled with the `release` configuration.\n\nWe can specify this when executing the script.\n\n```shell\ndotnet script foo.csx -c release\n```\n\n##\n\n## Nullable reference types\n\nStarting from version 0.50.0, `dotnet-script` supports .Net Core 3.0 and all the C# 8 features.\nThe way we deal with [nullable references types](https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references) in `dotnet-script` is that we turn every warning related to nullable reference types into compiler errors. This means every warning between `CS8600` and `CS8655` are treated as an error when compiling the script.\n\nNullable references types are turned off by default and the way we enable it is using the `#nullable enable` compiler directive. This means that existing scripts will continue to work, but we can now opt-in on this new feature.\n\n```csharp\n#!/usr/bin/env dotnet-script\n\n#nullable enable\n\nstring name = null;\n```\n\nTrying to execute the script will result in the following error\n\n```shell\nmain.csx(5,15): error CS8625: Cannot convert null literal to non-nullable reference type.\n```\n\nWe will also see this when working with scripts in VS Code under the problems panel.\n\n![image](https://user-images.githubusercontent.com/1034073/65727087-0e982600-e0b7-11e9-8fa0-d16331ab948a.png)\n\n## Specifying an SDK\n\nStarting with `dotnet-script` 1.4.0 we can now specify the SDK to be used for a script. \n\nFor instance, creating a web server in a script is now as simple as the following.\n\n```csharp\n#r \"sdk:Microsoft.NET.Sdk.Web\"\n\nusing Microsoft.AspNetCore.Builder;\n\nvar a = WebApplication.Create();\na.MapGet(\"/\", () =\u003e \"Hello world\");\na.Run();\n```\n\n\u003e Please note the the only SDK currently supported is `Microsoft.NET.Sdk.Web`\n \n## Team\n\n- [Bernhard Richter](https://github.com/seesharper) ([@bernhardrichter](https://twitter.com/bernhardrichter))\n- [Filip W](https://github.com/filipw) ([@filip_woj](https://twitter.com/filip_woj))\n\n## License\n\n[MIT License](https://github.com/dotnet-script/dotnet-script/blob/master/LICENSE)\n - \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-script%2Fdotnet-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotnet-script%2Fdotnet-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-script%2Fdotnet-script/lists"}