microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
234 stars 13 forks source link

[BUG] Doesn't work correctly with custom .NET Install location #1091

Open n00j opened 6 months ago

n00j commented 6 months ago

Describe the Issue

  1. Using Remote-SSH with a custom .net install location /home/agupta5/.dotnet Solution explorer doesn't load

  2. Using a devcontainer with a custom .net install location /home/agupta5/.dotnet, when you try to run with the debugger attached, it cannot find the .NET SDK

Steps To Reproduce

Remote SSH

  1. Don't have a global .net sdk installed on the machine.
  2. Install the SDK to a custom location. In my case I installed it to /home/agupta5/.dotnet The SDK was installed via this guide: https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual
    wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
    chmod +x ./dotnet-install.sh
    ./dotnet-install.sh --install-dir ~/.dotnet --version latest
    ./dotnet-install.sh --install-dir ~/.dotnet --channel 7.0 --version latest
    ./dotnet-install.sh --install-dir ~/.dotnet --channel 6.0 --version latest
  3. In my settings.json for vscode:
    ...
        "omnisharp.dotNetCliPaths": [
            "/home/agupta5/.dotnet/dotnet"
        ],
        "dotnet.dotnetPath": "/home/agupta5/.dotnet",
        "dotnetAcquisitionExtension.existingDotnetPath": [
            {
                "extensionId": "ms-dotnettools.csdevkit",
                "path": "/home/agupta5/.dotnet/dotnet"
            },
            {
                "extensionId": "ms-dotnettools.csharp",
                "path": "/home/agupta5/.dotnet/dotnet"
            },
            {
                "extensionId": "ms-dotnettools.vscode-dotnet-runtime",
                "path": "/home/agupta5/.dotnet/dotnet"
            },
            {
                "extensionId": "ms-dotnettools.vscodeintellicode-csharp",
                "path": "/home/agupta5/.dotnet/dotnet"
            }
        ],
    ...
  4. The extension runs fine, but the solution explorer says One or more errors occured. (No installed .NET SDK was found on the computer. If it is installed, make sure it can be found through the PATH environment variable. image

Dev Container

  1. Open this project in a dev container in WSL: https://github.com/n00j/dotnetdevkitbug

  2. In the devcontainer the solution loads correctly, but right-clicking on the project -> Debug -> start new instance returns in the missing sdk error:

    ------------------------------------------------------------------------------
    You may only use the Microsoft Visual Studio .NET/C/C++ Debugger (vsdbg) with
    Visual Studio Code, Visual Studio or Visual Studio for Mac software to help you
    develop and test your applications.
    ------------------------------------------------------------------------------
    You must install .NET to run this application.
    
    App: /workspaces/replicate/bin/Debug/net8.0/dotnettest
    Architecture: x64
    App host version: 8.0.4
    .NET location: Not found
    ...
  3. Right click Project -> Debug -> Start Without Debugging start_without_debugging

    root@184d41b68b47:/workspaces/replicate#  /root/.vscode-server/extensions/ms-dotnettools.csharp-2.23.15-linux-x64/.debugger/vsdbg --interpreter=vscode --connection=/tmp/CoreFxPipe_vsdbg-ui-809e4eb48b6945668bde4da4da7f90bb 
    You must install .NET to run this application.
    
    App: /workspaces/replicate/bin/Debug/net8.0/dotnettest
    Architecture: x64
    App host version: 8.0.4
    .NET location: Not found
    
    Learn more:
    https://aka.ms/dotnet/app-launch-failed
    
    Download the .NET runtime:
    https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=linux-x64&os=ubuntu.22.04&apphost_version=8.0.4
    
    root@184d41b68b47:/workspaces/replicate# echo $PATH
    /vscode/vscode-server/bin/linux-x64/e7e037083ff4455cf320e344325dacb480062c3c/bin/remote-cli:/workdir/.dotnet:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    
    root@184d41b68b47:/workspaces/replicate# which dotnet
    /workdir/.dotnet/dotnet
    
    root@184d41b68b47:/workspaces/replicate# dotnet --info
    .NET SDK:
     Version:           8.0.204
     Commit:            c338c7548c
     Workload version:  8.0.200-manifests.9f663350
    
    Runtime Environment:
     OS Name:     ubuntu
     OS Version:  22.04
     OS Platform: Linux
     RID:         linux-x64
     Base Path:   /workdir/.dotnet/sdk/8.0.204/
     ...

Expected Behavior

I expect C# Dev Toolkit to work correctly with a custom SDK install in a devcontainer or using remote-ssh without a global SDK install being available.

Environment Information

n00j commented 6 months ago

I also tried this with the latest pre-release: 1.5.18

Does vsdbg have some hardcoded search paths? and ignores $PATH variable?

AbhitejJohn commented 6 months ago

Tagging @WardenGnaw for thoughts on this.

AbhitejJohn commented 6 months ago

Coming back to this, it seems very similar to #792. If you think so as well @WardenGnaw and there's nothing specific we'd need to do on the debugger side, please feel free to resolve against that.

n00j commented 6 months ago

In that other one, it says it's "loading the sdk from the path". In this case, sdk on the path is pointing to the same location. It looks like it's completely ignoring the $PATH and the settings in vscode.