-
Notifications
You must be signed in to change notification settings - Fork 123
References and Scripts
Will Fuqua edited this page Jun 14, 2026
·
1 revision
Use the #r directive to add references during a session.
- Assembly:
#r "AssemblyName"or#r "path/to/assembly.dll" - Project:
#r "path/to/project.csproj" - Solution:
#r "path/to/solution.sln"(or.slnx) - NuGet, latest version:
#r "nuget: PackageName" - NuGet, specific version:
#r "nuget: PackageName, 13.0.5"
To add references when the REPL starts, use --reference (-r). See Configuring CSharpRepl.
Run a C# script file (.csx) with #load:
> #load "path/to/script.csx"Any references, namespaces, and variables the script defines stay available afterward. This is useful for a startup profile that loads the libraries you reach for often.
You can also pass a .csx file on the command line to run it before the prompt starts:
csharprepl path/to/script.csxArguments after -- are forwarded to the script and available in a global args variable:
csharprepl script.csx -- arg1 arg2To work with an application that uses a shared framework (for example ASP.NET Core), start with --framework, then reference the application DLL:
csharprepl --framework Microsoft.AspNetCore.App> #r "path/to/MyWebApp.dll"