dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.87k stars 675 forks source link

VS Code can't find DEBUG configuration .NET #7158

Closed niclastrelle closed 2 months ago

niclastrelle commented 5 months ago

Issue Description

The debug configuration to use .NET does not appear even if .NET runtimes are installed and run in the console.

Also, the .NET installer does not work and gives back the following error when trying to install a new .NET SDK with:

user requested to download the .NET SDK.
Error
Failed to download .NET -global:
No version was defined to install.

ms-dotnettools.csdevkit requested to download the .NET SDK.
Downloading .NET version(s) 8.0.300-global~x64 ...Cancelled Installation of .NET 8.0.300-global.
The requested version Der is invalid.
Error
Failed to download .NET 8.0.300-global:
.NET Acquisition Failed: The requested version Der is invalid.

Also does not work, when changing in settings.json dotnetAcquisitionExtension.existingDotnetPath to:

{
    "workbench.colorTheme": "Default Dark Modern",
    "workbench.startupEditor": "none",
    "cmake.options.statusBarVisibility": "compact",
    "git.autofetch": true,
    "omnisharp.enableMsBuildLoadProjectsOnDemand": true,
    "dotnetAcquisitionExtension.existingDotnetPath": [
        {
            "extensionId": "ms-dotnettools.csharp",
            "path": "C:\\Program Files\\dotnet\\dotnet.exe"
        }
    ],
    "telemetry.telemetryLevel": "off",
    "dotnetAcquisitionExtension.enableTelemetry": false
}

Steps to Reproduce

Install more than one runtimes.

Environment information

VSCode version: 1.89.1 C# Extension: 2.30.28 Using OmniSharp: false

Dotnet Information .NET SDK: Version: 8.0.300 Commit: 326f6e68b2 Workload version: 8.0.300-manifests.818b3449 MSBuild version: 17.10.4+10fbfbf2e Runtime Environment: OS Name: Windows OS Version: 10.0.22631 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.300\ .NET workloads installed: There are no installed workloads to display. Host: Version: 8.0.5 Architecture: x64 Commit: 087e15321b .NET SDKs installed: 6.0.422 [C:\Program Files\dotnet\sdk] 8.0.205 [C:\Program Files\dotnet\sdk] 8.0.300 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation] Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
Visual Studio Code Extensions |Extension|Author|Version|Folder Name| |---|---|---|---| |csdevkit|ms-dotnettools|1.6.8|ms-dotnettools.csdevkit-1.6.8-win32-x64| |csharp|ms-dotnettools|2.30.28|ms-dotnettools.csharp-2.30.28-win32-x64| |debugpy|ms-python|2024.6.0|ms-python.debugpy-2024.6.0-win32-x64| |dotnet-interactive-vscode|ms-dotnettools|1.0.5229040|ms-dotnettools.dotnet-interactive-vscode-1.0.5229040| |jupyter|ms-toolsai|2024.4.0|ms-toolsai.jupyter-2024.4.0-win32-x64| |jupyter-keymap|ms-toolsai|1.1.2|ms-toolsai.jupyter-keymap-1.1.2| |jupyter-renderers|ms-toolsai|1.0.17|ms-toolsai.jupyter-renderers-1.0.17| |python|ms-python|2024.6.0|ms-python.python-2024.6.0| |vscode-dotnet-pack|ms-dotnettools|1.0.13|ms-dotnettools.vscode-dotnet-pack-1.0.13| |vscode-dotnet-runtime|ms-dotnettools|2.0.5|ms-dotnettools.vscode-dotnet-runtime-2.0.5| |vscode-jupyter-cell-tags|ms-toolsai|0.1.9|ms-toolsai.vscode-jupyter-cell-tags-0.1.9| |vscode-jupyter-slideshow|ms-toolsai|0.1.6|ms-toolsai.vscode-jupyter-slideshow-0.1.6| |vscode-pylance|ms-python|2024.5.1|ms-python.vscode-pylance-2024.5.1|;
dibarbet commented 5 months ago

The debug configuration to use .NET does not appear even if .NET runtimes are installed and run in the console.

@niclastrelle would you mind expanding on this, or providing a screenshot of what isn't working? I'm not quite understanding from the description. Would also request the contents of the 'C#' output window.

I do see the error in the runtime download extension, tagging @nagilson incase he's seen that before - this seems weird

ms-dotnettools.csdevkit requested to download the .NET SDK.
Downloading .NET version(s) 8.0.300-global~x64 ...Cancelled Installation of .NET 8.0.300-global.
The requested version Der is invalid.
nagilson commented 5 months ago

@niclastrelle Which version of the .NET SDK do you want to install? When you run the command, you need to specify the version such as '6.0' or '6.0.1xx', etc.

@dibarbet I think this user is trying to use the existing path for the SDK. We do return that existing path for the SDK when DevKit requests us to install the SDK, but I don't think C# / DevKit has logic to use that path for when it looks for the SDK. We might wanna talk about that.

Regarding the user error, @dibarbet we added a new way to install the SDK in Feb that released from the API we delivered in Oct. The UI for the SDK in DevKit has also released, but this earlier method is a command pallete command that allows users to enter a specific desired SDK version, if the UI options don't meet their demands. (We also did it to get some data on the success rate before the UI launch.)

This feature is documented on https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.vscode-dotnet-runtime. Whenever it's used it says 'user' is requesting the SDK. Here, the user first ran the command and when prompted for a version to install, entered no string. Then the second time they entered 'Der' as the version to install, which we rejected as an invalid version to install.

niclastrelle commented 5 months ago

The debug configuration to use .NET does not appear even if .NET runtimes are installed and run in the console.

@niclastrelle would you mind expanding on this, or providing a screenshot of what isn't working? I'm not quite understanding from the description. Would also request the contents of the 'C#' output window.

I do see the error in the runtime download extension, tagging @nagilson incase he's seen that before - this seems weird

ms-dotnettools.csdevkit requested to download the .NET SDK.
Downloading .NET version(s) 8.0.300-global~x64 ...Cancelled Installation of .NET 8.0.300-global.
The requested version Der is invalid.

image

I was not able to choose the .NET configuration only via the UI. I fixed this issue with building the assets manually with the following command:

>.NET Generate Assets for Build and Debug

Now I can use the .NET configuration in the debug configuration properly.

Regarding the downloading issue. This is still not resolved - I had to install .NET manually.

To better resolve the underlying issue I tried right now again with the .NET installer. My specified version was:

8.0.300

image

After pressing enter I get the already provided error output.

user requested to download the .NET SDK.
Downloading .NET version(s) 8.0.300-global~x64 ...Cancelled Installation of .NET 8.0.300-global.
The requested version Der is invalid.
Error
Failed to download .NET 8.0.300-global:
.NET Acquisition Failed: The requested version Der is invalid.

user requested to download the .NET SDK.
Error
Failed to download .NET -global:
No version was defined to install.
nagilson commented 5 months ago

@niclastrelle

Thank you for providing some more information. May you also provide some of the installer logs?

❗ Privacy Alert! The contents in our log files may contain personal data. Prior to posting to GitHub, please remove any personal data which should not be publicly viewable. https://privacy.microsoft.com/en-US/privacystatement

Our log files are located alongside VS Code logs. If you want to find them manually, navigate here: Linux: ~/.config/Code/logs Mac: ~/Library/Application Support/Code/logs/ Windows: c:\Users\USER\AppData\Roaming\Code\logs\

Then find the folder created at the time you experienced the bug in the logs folder. From there, go to window1 -> exthost -> ms-dotnettools.vscode-dotnet-runtime. The log file should be located in this folder.

Note: The window folder may change depending on how many VS Code windows you have open; if our extension is running in the 2nd window, it'd be in a folder called window2.

suschmeister commented 5 months ago

You can fix this by switching your Windows display language to english during the installation.

nagilson commented 5 months ago

Interesting, thank you. So it sounds like we might have an issue parsing with different display languages. cc @baronfel for awareness. I will need to try this out.

Logs would still be helpful!

niclastrelle commented 5 months ago

DotNetAcquisition-ms-dotnettools.vscode-dotnet-runtime-1716464489368.txt

nagilson commented 5 months ago

Thank you, that was helpful! It actually looks like it succeeded to install but reported an error anyway. If you go to program files, is the SDK 8.0.301 installed? My guess is that it did install.

The failure is actually happening during registry lookup because the registry lookup is returning output in a different language. I will need to fix this bug.

nagilson commented 5 months ago

I have a PR linked that should fix this pending the next release.

niclastrelle commented 5 months ago

Thank you, that was helpful! It actually looks like it succeeded to install but reported an error anyway. If you go to program files, is the SDK 8.0.301 installed? My guess is that it did install.

The failure is actually happening during registry lookup because the registry lookup is returning output in a different language. I will need to fix this bug.

Yes, it got installed - but I also installed it before manually, so I don't really know if it installed or just referenced to the already installed SDK. Still, It is highly likely that you found the underlying issue.

Thank you for helping :)

dibarbet commented 2 months ago

Closing - the linked PR is merged and I believe should be released now.