I’m just some guy from the internet, not the internal team, but I have some potentially interesting feedback that you may find handy. Or it’s the ramblings of a mad man. You decide!
Further down is a mad suggestion.
Also, unrelated I was trying to debug what’s going on with the existing snap, then realised I am on an arm64 machine and the build that’s published for arm64 is very old (2020) and broken.
alan@asimo:~$ snap info dotnet-sdk
name: dotnet-sdk
summary: Develop high performance applications in less time, on any platform.
publisher: Microsoft .NET Core (dotnetcore✓)
store-url: https://snapcraft.io/dotnet-sdk
contact: https://dot.net/core
license: unset
description: |
.NET Core is the modular and high performance implementation of .NET for creating web applications
and services that run on Windows, Linux and Mac. It is open source and it can share the same code
with .NET Framework and Xamarin apps.
.NET Core is a .NET Foundation project. https://dotnetfoundation.org/
commands:
- dotnet-sdk.dotnet
snap-id: uHc4y9lWxyqYfxsqcr4xILzAai4L1BHs
tracking: 5.0/edge
refresh-date: today at 20:00 BST
channels:
5.0/stable: –
5.0/candidate: –
5.0/beta: –
5.0/edge: 5.0.100-preview.3.20216.6 2020-04-21 (79) 127MB classic
installed: 5.0.100-preview.3.20216.6 (79) 127MB classic
So, number one, I’d unpublish that.
Now, I’m slightly annoyed with myself for wasting 10 minutes on that, but that’s very much a “me problem”.
(ok, sshing over to an amd64 box)
My theory is you can actually test what happens if there was a dotnet snap and a dotnet-sdk yourself on a developer workstation.
My theory is you could snap install the one called ‘dotnet-sdk’ in the store, then locally modify a build, to make a ‘dotnet’ snap on your workstation, install that, and see what happens.
So, let’s do that…
$ snap info dotnet-sdk
name: dotnet-sdk
summary: Develop high performance applications in less time, on any platform.
publisher: Microsoft .NET Core (dotnetcore✓)
store-url: https://snapcraft.io/dotnet-sdk
contact: https://dot.net/core
license: MIT
description: |
.NET Core is the modular and high performance implementation of .NET for creating web applications
and services that run on Windows, Linux and Mac. It is open source and it can share the same code
with .NET Framework and Xamarin apps.
.NET Core is a .NET Foundation project. https://dotnetfoundation.org/
snap-id: uHc4y9lWxyqYfxsqcr4xILzAai4L1BHs
channels:
latest/stable: 8.0.204 2024-04-09 (241) 293MB classic
latest/candidate: ↑
latest/beta: 8.0.100-rc.1.23455.8 2023-09-12 (222) 285MB classic
latest/edge: ↑
lts/stable: 8.0.204 2024-04-09 (241) 293MB classic
lts/candidate: ↑
lts/beta: ↑
lts/edge: ↑
8.0/stable: 8.0.204 2024-04-09 (241) 293MB classic
8.0/candidate: ↑
8.0/beta: 8.0.100-rc.2.23502.2 2023-10-10 (225) 285MB classic
8.0/edge: ↑
7.0/stable: 7.0.408 2024-04-09 (242) 289MB classic
7.0/candidate: ↑
7.0/beta: 7.0.100-rc.2.22477.23 2022-10-11 (182) 266MB classic
7.0/edge: ↑
6.0/stable: 6.0.421 2024-04-09 (240) 265MB classic
6.0/candidate: ↑
6.0/beta: ↑
6.0/edge: ↑
5.0/stable: 5.0.408 2022-05-10 (167) 139MB classic
5.0/candidate: ↑
5.0/beta: ↑
5.0/edge: ↑
3.1/stable: 3.1.426 2022-12-13 (189) 213MB classic
3.1/candidate: ↑
3.1/beta: ↑
3.1/edge: ↑
2.1/stable: 2.1.818 2021-08-19 (139) 245MB classic
2.1/candidate: ↑
2.1/beta: ↑
2.1/edge: ↑
Ok, that’s more like it!
Let’s install it. I’ll pick an older version, so we can ‘simulate’ a ‘future upgrade’ in a bit.
$ snap install dotnet-sdk --channel=7.0/stable --classic
dotnet-sdk (7.0/stable) 7.0.408 from Microsoft .NET Core (dotnetcore✓) installed
Does it have a dotnet
command/alias?
$ snap info dotnet-sdk | grep -A 1 ^commands
commands:
- dotnet-sdk.dotnet
$ snap aliases
Command Alias Notes
dotnet-sdk.dotnet dotnet -
Does it work?
$ which dotnet
/snap/bin/dotnet
$ dotnet --version
7.0.408
Ok, good, let’s download a different version and modify it.
$ mkdir dn
$ cd dn
$ snap download dotnet-sdk --channel=8.0/stable
Fetching snap "dotnet-sdk"
Fetching assertions for "dotnet-sdk"
Install the snap with:
snap ack dotnet-sdk_241.assert
snap install dotnet-sdk_241.snap
We can unpack it…
$ unsquashfs dotnet-sdk_241.snap
Parallel unsquashfs: Using 8 processors
9150 inodes (15793 blocks) to write
[=======================================\] 24943/24943 100%
created 8879 files
created 1162 directories
created 271 symlinks
created 0 devices
created 0 fifos
created 0 sockets
created 0 hardlinks
Let’s change the name of the snap from dotnet-sdk
to dotnet
. This will automagically make this snap have the dotnet
‘alias’ given the name of the command, and the name of the snap are the same.
$ cat squashfs-root/meta/snap.yaml
name: dotnet-sdk
version: 8.0.204
summary: Cross-Platform .NET Core SDK
description: '.NET Core SDK. https://dot.net/core.
'
apps:
dotnet:
command: dotnet
architectures:
- amd64
base: core20
confinement: classic
grade: stable
$ sed -i 's|-sdk||' squashfs-root/meta/snap.yaml
$ grep sdk squashfs-root/meta/snap.yaml
Now, let’s pack it back up as a snap.
$ snap pack ./squashfs-root
built: dotnet_8.0.204_amd64.snap
Ok, let’s install that.
$ snap install ./dotnet_8.0.204_amd64.snap --dangerous --classic
error: cannot install snap file: snap "dotnet" command namespace conflicts with alias "dotnet" for
"dotnet-sdk" snap
Boom! Explosions, fire, brimstone, end of the world.
Even if you could have aliases in both snaps, it’s not possible to have them both installed.
There’s your answer. 
Now, what you do about this, is the interesting question. Migrations from one snap to another are always a bit manky to be honest. I would take the ‘nudge’ approach. You could add a simple ‘echo’ in the wrapper that launches dotnet-sdk.dotnet
to inform the user. Maybe echo a URL, or if you’re feeling brutal, use xdg-open to launch a browser to a URL containing documentation.
Mad idea zone…
Has someone on the store team explicitly stated that you cannot have a snap called dotnet
published in the store (not installed in parallel) while you have another snap (dotnet-sdk
) which has the dotnet
alias? (so-called ‘option 1’).
The documentation doesn’t appear to imply that.
There’s possibly a further option.
I don’t know what the userbase (weekly active devices) of the dotnet-sdk
is, nor how often they use it, but in my experience you won’t get everyone migrated in two months. You often find tons of people install snaps and then don’t use them, so they will show up in the store metrics, but won’t see blog posts, announcements or the like.
We have had people keep stuff installed, because they’re not active users of the package, for a very, very long time.
One thing that I suspect people will frown upon is to actively fix the problem from inside the snap.
So from inside the dotnet-sdk
snap you could (potentially, if allowed by The Powers That Be) do something brutal like display a messgae, which would appear on the developer workstation, or in logs, if it’s in CI. This could tell the user to ‘snap remove dotnet-sdk; snap install dotnet’.
The dotnet-sdk snap, and presumably the dotnet snap is classic though, so you could (if allowed) detect an interactive shell and prompt the user ‘fix this (y/n)’ then do the ‘snap unalias dotnet-sdk.dotnet ; snap install dotnet ; snap remove dotnet-sdk’.
Something like a shell script wrapper around the dotnet
binary, inside the dotnet-sdk
snap which does the above.
If you published that before the dotnet
snap is promoted, it would enable people to migrate early rather than be surprised.
(if allowed)