Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update dotnet skd and runtime when installed on GitHub Codespaces #8948

Open
TheLarkInn opened this issue Nov 21, 2023 · 5 comments
Open
Labels
area-setup Issues related to installing .NET Core

Comments

@TheLarkInn
Copy link

TheLarkInn commented Nov 21, 2023

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:

image

How, or what is the right way to update the sdk version.

  1. I first went to this tutorial to attempt to update with sudo apt-get update && sudo apt-get upgrade etc, however still the only version that was showing up as detected was the original version the codespace installs.

  2. 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 dotnet again, it still only detects the original version.

image

 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"
}
  1. 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.

image

Steps to reproduce

  1. Open any .dotnet project for example this one with the GitHub Universal Codespaces image 
  2. Attempt to use apt-get or dotnet-install.sh script to update dotnet version
  3. 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. 😛

@TheLarkInn
Copy link
Author

UPDATE: In a fresh codespace I was able to update to the correct version using the following steps:

  1. Launch codespace with default universal 2 image.
  2. Install dotnet-installer script.
  3. 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.

@rzikm
Copy link
Member

rzikm commented Nov 22, 2023

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?

@rzikm
Copy link
Member

rzikm commented Dec 4, 2023

@MichaelSimons Are you able to help here?

@MichaelSimons
Copy link
Member

@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.

@timheuer
Copy link
Member

@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.

@buyaa-n buyaa-n added area-setup Issues related to installing .NET Core and removed untriaged labels Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-setup Issues related to installing .NET Core
Projects
None yet
Development

No branches or pull requests

5 participants