KEMBAR78
GitHub - Beej126/CS_FileBasedApp_AutoExtension: sets up auto-run extension for new dotnet v10 "file based app" scripts
Skip to content

Beej126/CS_FileBasedApp_AutoExtension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS_FileBasedApp_AutoExtension

sets up auto-run extension for new dotnet v10 "file based app" scripts

basically sortof a "shebang" for Windows
(this general approach is readily applicable to any script engine you need, not just the "dotnet run" example here)

this enables launching .fba files

  1. from file explorer double click
  2. and without needing dotnet run in consoles (powershell, pwsh, cmd)
  3. nor needing to provide the file extension in consoles

install

  • just clone the repo
  • and run the csfba_setup.cmd

background

  • see msft launch video: https://devblogs.microsoft.com/dotnet/announcing-dotnet-run-app/
  • presenter touched on how we don't have convenience of linux "shebang" on Windows...
  • yet we actually can with a little scripted orchestration as provided here

  • the setup maps .fba (for file-based-app) to a runner script
    • feel free to change to your preferred extension at the top of the setup script
    • but make sure your extension is no more than 3 characters - otherwise a longstanding bug in traditional powershell opens a separate console process/window... and i believe i still saw this happening even under pwsh

  • the core "trick" of the runner script is very simple: it temporarily copies the .fba file to a .cs file so dotnet run is happy to compile it =)

  • arguments will be passed
  • due to adding .fba to %PATHEXT%, they will execute from anywhere in your %PATH%, just like .bat, et al
  • the custom extension is configured with a representative icon so our scripts stand out nicely in a folder
  • the setup and the script runner each call upon cli tools (setxx.exe and pids.exe) with repo sources provided in their comments
    • setxx.exe is a more robust tool like native setx... nicely handles otherwise sticky stuff related to setting global environment variables: simple add/remove by value, user vs system (with built in UAC elevation), option to uppercase the value... bing copilot banged it into shape over a few hours... i wish i had a tool like this decades ago! =)
    • the runner leverages pids.exe to know if it was launched via file explorer so it can keep the console open via timeout as a convenience to view any output... if this isn't important to you, feel free to drop the pids.exe dependency

About

sets up auto-run extension for new dotnet v10 "file based app" scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published