News for hackers. Stuff that matters.
Re:dotnet run app.cs by andix on Thursday May 29, 2025 @04:31PM (#44130080)
Is it possible to add those scripts project-scoped like with npm run? They should work for everyone who checks out the repo.
Re:dotnet run app.cs by smarx007 on Thursday May 29, 2025 @04:36PM (#44130131)
I think everyone needs to do `dotnet tool install -g dotnet-script` before running them. This is the most annoying part where .NET 10 announcement would be really appreciated.

But then each script has an individual list of dependencies so there should be no need for further scoping like in npm (as in, the compilation of the script is always scoped behind the scenes). In this regard, both should be similar to https://docs.astral.sh/uv/guides/scripts/#declaring-script-d... which I absolutely love.

Re:dotnet run app.cs by bladeee on Thursday May 29, 2025 @05:16PM (#44130468)
You can use project-scoped tool manifests. Then you can call dotnet tool restore to load all tools specified in the manifest.

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

Re:dotnet run app.cs by smarx007 on Thursday May 29, 2025 @05:19PM (#44130492)
TIL, thank you!
Re:dotnet run app.cs by andix on Saturday May 31, 2025 @02:36PM (#44146147)
Sure, but I think you still need to provide the full path of the script. If you're inside a source folder very deep it will lead to something like:

  dotnet script ../../../../../scrips/scaffold-something.cs
With npm run it works from any subdirectory:

  npm run scaffold-something