dotnet-execute
0.5.0
See the version list below for details.
dotnet tool install --global dotnet-execute --version 0.5.0
dotnet new tool-manifest
dotnet tool install --local dotnet-execute --version 0.5.0
#tool dotnet:?package=dotnet-execute&version=0.5.0
nuke :add-package dotnet-execute --version 0.5.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
Latest stable version:
dotnet tool update -g dotnet-execute
Latest preview version:
dotnet tool update -g dotnet-execute --prerelease
Examples
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 file with preview features:
dotnet-exec RawStringLiteral.cs --preview
Execute raw code:
dotnet-exec 'code:Console.WriteLine(1+1);'
Execute raw code with custom usings:
dotnet-exec 'code:WriteLine(1+1);' --using "static System.Console"
Execute raw code with docker
docker run --rm weihanli/dotnet-exec:0.4.0 dotnet-exec "code:(1+1).Dump()"
More
LanguageVersion
By default, it's using the latest language version, you can use the Preview version with --preview/--lang-version=Preview
EntryPoint
By default, it would use MainTest as the entry point, you can customize with --entry option
TargetFramework
By default, it would use net7.0 if you've installed .NET 7 SDK, otherwise use .NET 6 instead, you can customize with the -f/--framework option
CompilerType
By default, it would use the DefaultCodeCompiler to compile the code, you can customize with the --compiler-type option, and you can use -a/--advanced for --compiler-type=advanced
| 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 was computed. 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.