← Back to context

Comment by recursive

4 days ago

I've wanted this for a long time. After reading this link, and the MS release announcement, I still don't understand what a "tool" is, or how you can use `tool exec` to run a single *.cs file. Is there a straight-forward recipe anywhere for doing this targeted at absolute simpletons?

Well if you're familiar with the node ecosystem it's a corollary for npx/bunx/etc.

It is so that folks can build and run "tools" that are executed, utilizing the nuget ecosystem.

Relevant links in the dotnet docs (was just a quick google away):

* https://learn.microsoft.com/en-us/dotnet/core/tools/global-t...

* https://learn.microsoft.com/en-us/dotnet/core/tools/global-t...

It's actually a top-level doc section in the primary dotnet docs (https://learn.microsoft.com/en-us/dotnet/).

To boil it down: you create a console app, add a couple of attributes to the solution file (https://learn.microsoft.com/en-us/dotnet/core/tools/global-t...). Packaging and publishing to nuget (if you want to share with others) is via `dotnet pack` and `dotnet nuget push` with some flags.

I do have to say it's actually very well documented.

  • Sorry for being unclear. Using tools isn't my goal. I want to run a single *.cs file from the console. It may be possible to achieve this using tools, but I don't know how. I did read the resources I could find, and didn't find any information about this.

Sorry for confusing you. I can't edit the post now. The command is dotnet run script.cs. The tool stuff is about something else unrelated; NuGet installable CLI executables.