dotnet-execute 0.12.0-preview-20221203-104240

This is a prerelease version of dotnet-execute.
There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global dotnet-execute --version 0.12.0-preview-20221203-104240
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local dotnet-execute --version 0.12.0-preview-20221203-104240
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=dotnet-execute&version=0.12.0-preview-20221203-104240&prerelease
nuke :add-package dotnet-execute --version 0.12.0-preview-20221203-104240

dotnet-exec

dotnet-execute

dotnet-execute Latest

default

Docker Pulls

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

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.3.0" -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'

image

Executing with specific profile config and remove preset specific using:

dotnet-exec 'WebApplication.Create().Run();' --profile web --using '-WeihanLi.Extensions'

Docker 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"

for full image tag list, see https://hub.docker.com/r/weihanli/dotnet-exec/tags

Acknowledgements

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
0.22.0-preview-20240625-162946 22 6/25/2024
0.22.0-preview-20240623-012555 65 6/23/2024
0.21.0 654 6/15/2024
0.21.0-preview-20240612-121807 119 6/12/2024
0.20.0 497 6/6/2024
0.20.0-preview-20240524-051120 193 5/24/2024
0.20.0-preview-20240515-154245 185 5/15/2024
0.20.0-preview-20240514-011719 143 5/14/2024
0.20.0-preview-20240508-180124 158 5/8/2024
0.20.0-preview-20240504-132024 163 5/4/2024
0.20.0-preview-20240430-154848 134 4/30/2024
0.19.0 1,691 4/21/2024
0.19.0-preview-20240421-150257 149 4/21/2024
0.19.0-preview-20240418-124656 119 4/18/2024
0.19.0-preview-20240414-090727 348 4/14/2024
0.19.0-preview-20240325-125324 476 3/25/2024
0.19.0-preview-20240313-155620 492 3/13/2024
0.19.0-preview-20240302-202752 791 3/2/2024
0.18.1 2,457 3/2/2024
0.18.0 693 3/1/2024
0.18.0-preview-20240229-183143 733 2/29/2024
0.18.0-preview-20240229-171025 694 2/29/2024
0.18.0-preview-20240229-170010 576 2/29/2024
0.18.0-preview-20240229-133804 625 2/29/2024
0.18.0-preview-20240225-075052 653 2/25/2024
0.18.0-preview-20240218-125959 661 2/18/2024
0.17.0 1,066 2/6/2024
0.17.0-preview-20240206-052156 653 2/6/2024
0.17.0-preview-20240201-150911 801 2/1/2024
0.17.0-preview-20240127-065141 1,113 1/27/2024
0.17.0-preview-20240117-161410 838 1/17/2024
0.16.0 1,390 1/5/2024
0.16.0-preview-20240105-112404 1,312 1/5/2024
0.16.0-preview-20240105-111327 1,146 1/5/2024
0.16.0-preview-20240104-161712 1,022 1/4/2024
0.16.0-preview-20240104-064502 1,071 1/4/2024
0.16.0-preview-20240103-183808 996 1/3/2024
0.16.0-preview-20240102-132944 1,243 1/2/2024
0.16.0-preview-20240101-163843 1,199 1/1/2024
0.16.0-preview-20231230-064352 1,130 12/30/2023
0.16.0-preview-20231230-045759 1,038 12/30/2023
0.16.0-preview-20231230-043451 1,219 12/30/2023
0.16.0-preview-20231230-040947 1,290 12/30/2023
0.16.0-preview-20231229-151551 1,241 12/29/2023
0.16.0-preview-20231227-032350 1,056 12/27/2023
0.15.0 1,485 11/23/2023
0.15.0-preview-20231123-133547 1,248 11/23/2023
0.15.0-preview-20231123-123533 1,376 11/23/2023
0.15.0-preview-20231123-113815 1,344 11/23/2023
0.15.0-preview-20231122-010942 1,462 11/22/2023
0.15.0-preview-20231112-135031 1,274 11/12/2023
0.15.0-preview-20231105-060850 1,221 11/5/2023
0.15.0-preview-20231011-155919 1,464 10/11/2023
0.15.0-preview-20230920-150633 1,529 9/20/2023
0.15.0-preview-20230916-043614 1,718 9/16/2023
0.15.0-preview-20230827-040803 1,718 8/27/2023
0.15.0-preview-20230715-072914 1,908 7/15/2023
0.15.0-preview-20230614-132940 1,650 6/14/2023
0.15.0-preview-20230517-162215 1,775 5/17/2023
0.14.0 2,000 4/22/2023
0.14.0-preview-20230419-153939 1,936 4/19/2023
0.14.0-preview-20230418-162203 1,748 4/18/2023
0.14.0-preview-20230415-012305 1,824 4/15/2023
0.14.0-preview-20230414-123704 1,747 4/14/2023
0.14.0-preview-20230412-140151 1,915 4/12/2023
0.14.0-preview-20230402-061327 2,133 4/2/2023
0.14.0-preview-20230327-163300 1,976 3/27/2023
0.14.0-preview-20230327-160902 1,914 3/27/2023
0.13.0 1,894 3/16/2023
0.13.0-preview-20230315-162605 1,859 3/15/2023
0.13.0-preview-20230226-133827 1,626 2/26/2023
0.13.0-preview-20230222-162344 1,837 2/22/2023
0.12.0 2,029 12/3/2022
0.12.0-preview-20221203-104240 1,689 12/3/2022
0.12.0-preview-20221203-071257 1,923 12/3/2022
0.12.0-preview-20221203-022812 1,830 12/3/2022
0.12.0-preview-20221202-163150 1,770 12/2/2022
0.12.0-preview-20221130-165115 1,769 11/30/2022
0.12.0-preview-20221130-004835 1,748 11/30/2022
0.12.0-preview-20221130-004015 1,863 11/30/2022
0.12.0-preview-20221129-162650 1,808 11/29/2022
0.12.0-preview-20221129-154228 1,841 11/29/2022
0.12.0-preview-20221129-152839 1,727 11/29/2022
0.12.0-preview-20221129-151920 1,693 11/29/2022
0.12.0-preview-20221126-142415 1,763 11/26/2022
0.12.0-preview-20221126-084550 1,629 11/26/2022
0.12.0-preview-20221126-081432 1,696 11/26/2022
0.12.0-preview-20221126-032548 1,705 11/26/2022
0.12.0-preview-20221125-161857 1,729 11/25/2022
0.11.0 1,917 11/22/2022
0.10.0 1,872 11/15/2022
0.9.0 1,838 11/9/2022
0.8.0 2,016 10/26/2022
0.7.0 2,149 7/17/2022
0.6.0 2,240 7/1/2022
0.5.0 2,188 6/26/2022
0.4.0 2,173 6/18/2022
0.3.0 2,598 6/5/2022
0.2.0 2,335 5/29/2022
0.1.1 4,721 5/4/2022
0.1.0 2,542 5/4/2022