4 ms·
This feature is probably a big thing for .NET developer productivity. It's quite a shame, that it only came now. There is another thing I'm really missing for
by andix 1y ago
This feature is probably a big thing for .NET developer productivity. It's quite a shame, that it only came now.
There is another thing I'm really missing for .NET projects. The possibility to easily define project-specific commands. Something like "npm run <command>"
- tylerflick 1y agoI remember using LINQPad when I needed this functionality filled.
- ryanbuening 1y agoAre you talking about this?: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-r...
- smarx007 1y ago> This feature is probably a big thing for .NET developer productivity. It's quite a shame, that it only came now. I am using https://github.com/dotnet-script/dotnet-script https://github.com/dotnet-script/dotnet-script without any issues. Skipping an extra step would be cool though.
- andix 1y agoIs it possible to add those scripts project-scoped like with npm run? They should work for everyone who checks out the repo.
- smarx007 1y agoI 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-dependencies https://docs.astral.sh/uv/guides/scripts/#declaring-script-d... which I absolutely love.
- bladeee 1y agoYou 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-tools https://learn.microsoft.com/en-us/dotnet/core/tools/global-t...
- smarx007 1y agoTIL, thank you!
- andix 1y agoSure, 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
- Inception 1y agoThis would be great! I'm currently using make files to accomplish this: https://www.gnu.org/software/make/ https://www.gnu.org/software/make/
- andix 1y agoHow can you use make as a script runner? Is it possible to add targets that are not part of the tree and execute every time you run them? something like make clear-test-database that runs every time you execute it, but is not executed on make all or make clean?
- mystified5016 1y agoNah, we've been doing this for years. At least ten years ago I built myself a little console based on Roslyn that would evaluate any C# snippets I gave it. C# scripts were pretty well supported, and it was not hard to throw one together. The engine of my console was a couple dozen lines mostly just processing the string. I'm sure the tooling is better now, though. I seem to recall visual studio and/or Rider also supporting something like this natively at the time.
- notnmeyer 1y agoyou’re better off using a separate task runner like make or task.
- andix 1y agoI don't think make and task are suited very well for running scripts that are not part of the build process. Something like scaffolding, or starting a dev dependency. Also it requires the developers to install additional tools to get started with the project.