dotnet-execute
0.14.0
See the version list below for details.
dotnet tool install --global dotnet-execute --version 0.14.0
dotnet new tool-manifest
dotnet tool install --local dotnet-execute --version 0.14.0
#tool dotnet:?package=dotnet-execute&version=0.14.0
nuke :add-package dotnet-execute --version 0.14.0
dotnet-exec
Intro
dotnet-exec is a command-line tool for executing C# program without a project file, and you can have your custom entry point other than Main method
Install/Update
dotnet tool
Latest stable version:
dotnet tool update -g dotnet-execute
Latest preview version:
dotnet tool update -g dotnet-execute --prerelease
Container support
Execute with docker
docker run --rm weihanli/dotnet-exec:latest dotnet-exec "1+1"
docker run --rm weihanli/dotnet-exec:latest dotnet-exec "Guid.NewGuid()"
docker run --rm --pull=always weihanli/dotnet-exec:latest dotnet-exec "ApplicationHelper.RuntimeInfo"
Execute with podman
podman run --rm weihanli/dotnet-exec:latest dotnet-exec "1+1"
podman run --rm weihanli/dotnet-exec:latest dotnet-exec "Guid.NewGuid()"
podman run --rm --pull=always weihanli/dotnet-exec:latest dotnet-exec "ApplicationHelper.RuntimeInfo"
for full image tag list, see https://hub.docker.com/r/weihanli/dotnet-exec/tags
Examples
Get started
Execute local file:
dotnet-exec HttpPathJsonSample.cs
Execute local file with custom entry point:
dotnet-exec 'HttpPathJsonSample.cs' --entry MainTest
Execute remote file:
dotnet-exec https://github.com/WeihanLi/SamplesInPractice/blob/master/net7Sample/Net7Sample/ArgumentExceptionSample.cs
Execute raw code:
dotnet-exec 'Console.WriteLine(1+1);'
Execute raw script:
dotnet-exec 'script:1+1'
dotnet-exec 'Guid.NewGuid()'
References
Execute raw code with custom references:
NuGet package reference:
dotnet-exec 'CsvHelper.GetCsvText(new[]{1,2,3}).Dump();' -r "nuget: WeihanLi.Npoi,2.4.2" -u "WeihanLi.Npoi"
Local dll reference:
dotnet-exec 'CsvHelper.GetCsvText(new[]{1,2,3}).Dump();' -r "./out/WeihanLi.Npoi.dll" -u "WeihanLi.Npoi"
Local dll in a folder references:
dotnet-exec 'CsvHelper.GetCsvText(new[]{1,2,3}).Dump();' -r "folder: ./out" -u "WeihanLi.Npoi"
Local project reference:
dotnet-exec 'CsvHelper.GetCsvText(new[]{1,2,3}).Dump();' -r "project: ./WeihanLi.Npoi.csproj" -u "WeihanLi.Npoi"
Framework reference:
dotnet-exec 'WebApplication.Create().Run();' --reference 'framework:web'
Web framework reference in one option:
dotnet-exec 'WebApplication.Create().Run();' --web
Usings
Execute raw code with custom usings:
dotnet-exec 'WriteLine(1+1);' --using "static System.Console"
Execute script with custom reference:
dotnet-exec 'CsvHelper.GetCsvText(new[]{1,2,3}).Dump()' -r "nuget:WeihanLi.Npoi,2.4.2" -u WeihanLi.Npoi
More
Execute with additional dependencies
dotnet-exec 'typeof(LocalType).FullName.Dump();' --ad FileLocalType2.cs
dotnet-exec 'typeof(LocalType).FullName.Dump();' --addition FileLocalType2.cs
Execute with exacting references and usings from the project file
dotnet-exec 'typeof(LocalType).FullName.Dump();' --project ./Sample.csproj
Execute file with preview features:
dotnet-exec RawStringLiteral.cs --preview
Config Profile
You can customize the config you used often into a config profile to reuse it for convenience.
List the profiles had configured:
dotnet-exec profile ls
Configure a profile:
dotnet-exec profile set web -r "nuget:WeihanLi.Web.Extensions" -u 'WeihanLi.Web.Extensions' --web --wide false
Get the profile details:
dotnet-exec profile get web
Remove the profile not needed:
dotnet-exec profile rm web
Executing with specific profile config:
dotnet-exec 'WebApplication.Create().Chain(_=>_.MapRuntimeInfo()).Run();' --profile web --using 'WeihanLi.Extensions'

Executing with specific profile config and remove preset specific using:
dotnet-exec 'WebApplication.Create().Run();' --profile web --using '-WeihanLi.Extensions'
Acknowledgements
- Roslyn
- NuGet.Clients
- System.CommandLine
- Thanks JetBrains for the open source Rider license
- Thanks the contributors and users for this project
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.34.0 | 1,062 | 1/23/2026 |
| 0.34.0-preview-20260123-150823 | 95 | 1/23/2026 |
| 0.34.0-preview-20251226-145429 | 240 | 12/26/2025 |
| 0.34.0-preview-20251225-160410 | 176 | 12/25/2025 |
| 0.34.0-preview-20251225-160006 | 170 | 12/25/2025 |
| 0.33.0 | 1,650 | 11/20/2025 |
| 0.33.0-preview-20251113-005230 | 321 | 11/13/2025 |
| 0.33.0-preview-20251015-123253 | 349 | 10/15/2025 |
| 0.32.0 | 1,803 | 9/11/2025 |
| 0.32.0-preview-20250911-001745 | 209 | 9/11/2025 |
| 0.32.0-preview-20250825-230929 | 318 | 8/25/2025 |
| 0.31.0 | 734 | 8/17/2025 |
| 0.31.0-preview-20250814-173628 | 233 | 8/14/2025 |
| 0.30.0 | 1,140 | 7/25/2025 |
| 0.30.0-preview-20250725-024058 | 520 | 7/25/2025 |
| 0.30.0-preview-20250724-010253 | 536 | 7/24/2025 |
| 0.30.0-preview-20250723-170211 | 586 | 7/23/2025 |
| 0.30.0-preview-20250723-163836 | 596 | 7/23/2025 |
| 0.30.0-preview-20250723-155751 | 595 | 7/23/2025 |
| 0.14.0 | 2,197 | 4/22/2023 |