core
core copied to clipboard
How to update `dotnet` skd and runtime when installed on GitHub Codespaces
Description
I have a project whos global.json provides the following sdk version:
{
"sdk": {
"version": "7.0.404"
}
}
When I used the GitHub Codespaces universal image (which does contain a preinstalled version of dotnet sdk., I get version 7.0.306. So of course when I attempt to use the dotnet cli or any other extension or attempt to build I get failures saying:
How, or what is the right way to update the sdk version.
-
I first went to this tutorial to attempt to update with
sudo apt-get update && sudo apt-get upgradeetc, however still the only version that was showing up as detected was the original version the codespace installs. -
I then attempted to use the dotnet-install.sh script and as you can see from the image I provided, it was installed, however when I run
dotnetagain, it still only detects the original version.
3. I then attempted to use a different devcontainer image (thinking that this would contain the most recent patch version of the 7.0 channel). I used the following image setting:
{
"image":"mcr.microsoft.com/devcontainers/dotnet:0-7.0"
}
- Then I rebuilt the dev container and instead got version 7.0.401. So I repeated steps 1-3 again just to make sure, and still was receiving 7.0.401 as the detected version:
Here is the terminal results from the dotnet-install script which says that 7.0.404 is installed but dotnet --info command only detecting 7.0.401.
Steps to reproduce
- Open any .dotnet project for example this one with the GitHub Universal Codespaces image
- Attempt to use
apt-getordotnet-install.shscript to update dotnet version - Observe it not detecting the correctly updated sdk.
I'm happy to reopen this in a different repo if helpful, and contribute documentation somewhere so that any first time dotnet users as myself don't have to waste multiple hours of troubleshooting to figure this headscratcher out. 😛
UPDATE: In a fresh codespace I was able to update to the correct version using the following steps:
- Launch codespace with default universal 2 image.
- Install
dotnet-installerscript. - Run `./dotnet-installer.sh --version 7.0.404
However I believe there is some sort of bug in the installer script when you use the other codespaces image or if you have already used sudo apt-get install ...
Also I feel like dotnet command line tool should just prompt the users to install the correct sdk/version when there is a mismatch. This is not a lot of extra work here and is just a great developer experience.
Not sure whom to ask regarding updating the mcr.microsoft.com/devcontainers/dotnet:0-7.0 image with latest SDK. Perhaps @carlossanlop can help redirect to the right place?
@MichaelSimons Are you able to help here?
@MichaelSimons Are you able to help here?
The .NET team does not own these images, they are produced by the devcontainers team (and are based on the .NET images). Please see https://mcr.microsoft.com/en-us/product/devcontainers/dotnet/about, specifically the Support section.
IDK what the version scheme is for this repo's images. The 0.-7.0 tag appears like a pinned tagged that is not intended to be updated. There are newer tags that contain 7.0.404. Try dev-7.0 or 1.1.0-dev.
@TheLarkInn thanks for logging the original issue here and the steps that worked. I believe you are right that installed via packages (apt) installs in a different location than the script which is why you may be seeing diff output from dotnet --info here (@baronfel can confirm I think).
But as a general guidance on Codespace images, I recommend folks find the best base image to use for their scenario. Some ideas:
- Universal is likely always going to try to stay on 'latest' versions of things and may be too broad for any one need.
- We created a new .NET specific Codespaces image that should be used now as well, but also is 'latest'
- I recommend folks use the best image for their needs, but then use the features mechanism to add additional SDKs or runtimes needed. You can use the .NET features like this:
{
"name": ".NET 8 with 7",
"image": "mcr.microsoft.com/dotnet/sdk:8.0",
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "none",
"dotnetRuntimeVersions": "7.0",
"aspNetCoreRuntimeVersions": "7.0"
}
}
}
That example above gives me .NET 8 base image but also installs latest 7.0.x versions of runtime. More on the .NET Feature can be found here: https://github.com/devcontainers/features/tree/main/src/dotnet
My personal default example now is to use the latest .NET SDK image as base, then add my features as I see fit. This gives me (and those working in my repo) the best curated Codespaces experience to start.