Publishing a CLI tool as a single-file app
So I've made a CLI tool (see #showcase) which I would sort of like to be able to distribute without requiring the .NET SDK for people to manually build and install it themselves. I know you can publish projects as single-file distributable applications, although is this possible to do with a CLI tool, or would you have to package it with some kind of installer?
44 Replies
Obviously I could just tell people to add it to their PATH themselves, although that sounds kind of dumb.
Single-file self-contained just get released as a single binary
So you end up with
tool.exe
for exampleyeah that sounds good
No need for any installers or anything. The user can just download the zip, unzip it wherever, and use it just like that
Except I would kind of like for users to not have to add it to their PATH themselves
The "installation" would just be doing that
That would need an installer of some sort then, yeah
Or the tool itself can have some function like that
The user can run
C:/Whatever/SomeLocation/tool.exe addpath
which will add it to PATH
, and from then on they can just call it with tool
Although setting PATH
with C# is wonky IMEDidn't know that, that's neat
Well, it's just a suggestion, not a built-in feature lol
Something you'd have to make yourself
Okay so easiest would just be to publish it as a single-file, then have users manually add it to their PATH
Probably, yeah
sounds reasonable
I don't really wanna have to make an installer for this or anything
Consider adding a help message for how to add it to the path
welp, too late now >_>
Is "dotnet tool install" something anyone can publish for? That's the best end-user experience I've seen for installing CLI tools
Well you need the .NET SDK to do that
<:PES_SadGe:814280618959568896>
you dont enable native aot for this tool? im curious abt the output size with native aot enabled
eh, I could, but it's not that important
it's only 58mb
(which I don't think is that big...?)
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Oh dear
winget is nice maybe things will improve in the future
As a conclusion, I think the thing I've come up with is that I'm gonna have an
install
command for my tool which adds the directory to the user's PATH, plus this also lets me set up additional configuration and stuff.so portable by default or install is required?
wdym?
Do I need to install to use the tool or can I just set directory and go
rn you can plop the exe inside a directory, add it to your path and go
I kinda wanna keep it like that, although it unfortunately means I can't do configuration or anything
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Well my current setup is this
1. Download latest release from my repo to some directory
2. Open directory in terminal
3. Run
./folder install
Which works decently enough imo
I've never used Winget so idk how to use it really
although to be fair this is kind of riskyUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
hmmmmm
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
The options I see are kind of these
- No automatic installation, user has to manually add executable to PATH
- Use
install
command (bad because running it from literally anywhere would add the current directory to PATH)
- Create some kind of an installer, no idea how to do thisUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
It just runs dotnet restore + build + pack + tool install
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I mean it's just for a local install so I don't have to run the command(s) manually
I could upload it to Nuget
I had an idea briefly to create an installer which fetches the latest release from the Github repo, although I'm fairly sure that'd run into multiple issues.
Mainly how to get the executable for the correct architecture
I mean it could work, although it feels like a hack
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I don't really know how you'd automatically create an installer like that.
Does the installer contain the executable itself?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
How do you include the program?
as an embedded resource?
actually you know what, i kind of see how you'd do that
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
mind sharing this script?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
also i have to go to sleep, but i'll be back to check this out later
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View