features icon indicating copy to clipboard operation
features copied to clipboard

How to change .NET version?

Open mcollier opened this issue 3 years ago • 3 comments

How do I use the additional .NET version installed by the dotnet feature? For example, if the feature is configured such as:

 "ghcr.io/devcontainers/features/dotnet:1": {
            "version": "7.0.306",
            "installUsingApt": "false",
            "additionalVersions": "6"
 }

How do I use .NET 6? When I run dotnet --list-sdks, only 7.0.306 [/usr/local/dotnet/7.0.306/sdk] is shown.

I can see 6.0.415 is present.

>ls -la /usr/local/dotnet/
total 24
drwxrwsr-x 1 codespace dotnet 4096 Oct 17 22:34 .
drwxr-xr-x 1 root      root   4096 Oct 17 22:44 ..
drwxrwsr-x 8 codespace dotnet 4096 Oct 17 22:34 6.0.415
drwxrwsr-x 1 codespace dotnet 4096 Oct 23 18:51 7.0.306
lrwxrwxrwx 1 codespace dotnet   25 Oct 17 22:34 current -> /usr/local/dotnet/7.0.306

My PATH environment variable seems to include only /usr/local/dotnet/current.

mcollier avatar Oct 23 '23 19:10 mcollier

Do I need to run ln -snf /usr/local/dotnet/6.0.415/ /usr/local/dotnet/current after the container starts in order to change the .NET version used?

mcollier avatar Oct 23 '23 21:10 mcollier

Hi 👋

Can you try with version 2 of the dotnet Feature? Eg. https://github.com/devcontainers/features/tree/main/src/dotnet#configuration-examples

It has the fix for the issue you are seeing ^. We recently had an amazing PR contribution from the community (kudos to @sliekens ✨ )

Eg. 👇

Image

Note: Moved this issue to the Features repo due to it's relevancy.

samruddhikhandale avatar Oct 23 '23 23:10 samruddhikhandale

Is it possible to control the installation version by reading from env?

"ghcr.io/devcontainers/features/dotnet:1": {
            "version": "${containerEnv:VERSION}",
            "installUsingApt": "false",
            "additionalVersions": "6"
 }
"containerEnv": {
  "VERSION": "1.19.2"
}

zouyee avatar Feb 11 '25 02:02 zouyee