dotnet / vscode-dotnet-runtime

VSCode Extension for Installing .NET via VS Code
MIT License
140 stars 267 forks source link

VS Code Extension failing to install .NET 7.0.9 #1147

Open m-bennett opened 1 year ago

m-bennett commented 1 year ago

Repro steps:

  1. I'm using VS Code version 1.81.0 on Ubuntu 23.04. Checking .NET versions I get the following:

dotnet --list-runtimes Microsoft.AspNetCore.App 7.0.9 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 7.0.9 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

dotnet --list-sdks 7.0.109 [/usr/lib/dotnet/sdk]

  1. The problem started occurring just after updating my software, including VS Code and a bunch of other stuff.

  2. Open a .NET project, and I see a message saying that it is downloading .NET version 7.0.9, then fails after about 10 seconds with the following error.

Extension Version: 1.0.0 Error Message: .NET Acquisition Failed: Installation failed: Error: Command failed: "/home/anonymous/.vscode/extensions/ms-dotnettools.vscode-dotnet-runtime-1.6.0/dist/install scripts/dotnet-install.sh" -InstallDir "/home/anonymous/.config/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.9" -Version 7.0.9 -Runtime dotnet

gzip: stdin: unexpected end of file tar: Child returned status 1 tar: Error is not recoverable: exiting now dotnet_install: Error: Extraction failed

Error Stack: Error: .NET Acquisition Failed: Installation failed: Error: Command failed: "/home/anonymous/.vscode/extensions/ms-dotnettools.vscode-dotnet-runtime-1.6.0/dist/install scripts/dotnet-install.sh" -InstallDir "/home/anonymous/.config/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.9" -Version 7.0.9 -Runtime dotnet

gzip: stdin: unexpected end of file tar: Child returned status 1 tar: Error is not recoverable: exiting now dotnet_install: Error: Extraction failed

at /home/anonymous/.vscode/extensions/ms-dotnettools.vscode-dotnet-runtime-1.6.0/dist/extension.js:2:4766
batteredhedgehog commented 1 year ago

Seeing the same problem

neolib commented 1 year ago

Same here on Windows 11.

gkalnytskyi commented 1 year ago

I have a similar installation problem on Windows 10. The action of downloading .Net Runtime 7.0.9 ends with the error (see below, with personal info removed). Each time extension attempts to load the DotNet Runtime, the different file is listed as locked.

Command failed: powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 ; & '%HOMEPATH%\.vscode\extensions\ms-dotnettools.vscode-dotnet-runtime-1.6.0\dist\install scripts\dotnet-install.ps1' -InstallDir '%HOMEPATH%\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.9' -Version 7.0.9 -Runtime dotnet }
dotnet-install: Failed to extract package. Exception: Exception calling "ExtractToFile" with "3" argument(s): "The process cannot access the file '%HOMEPATH%\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.9\shared\Microsoft.NETCore.App\7.0.9\clrgc.dll' because it is being used by another process."
Exception calling "ExtractToFile" with "3" argument(s): "The process cannot access the file %HOMEPATH%\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.9\shared\Microsoft.NETCore.App\7.0.9\clrgc.dll' because it is being used by another process."
At %HOMEPATH%\.vscode\extensions\ms-dotnettools.vscode-dotnet-runtime-1.6.0\dist\install scripts\dotnet-install.ps1:834 char:21
+ ...             [System.IO.Compression.ZipFileExtensions]::ExtractToFile( ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : IOException

I'm not sure why this command is failing. Searching using Process Explorer did not yield any results, and running the mentioned command (see sanitized version below with the closing double quote added) directly from CMD/Powershell returns dotnet-install: .NET Core Runtime with version '7.0.9' is already installed.

powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 ; & %HOMEPATH%\.vscode\extensions\ms-dotnettools.vscode-dotnet-runtime-1.6.0\dist\install scripts\dotnet-install.ps1' -InstallDir '%HOMEPATH%\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.9' -Version 7.0.9 -Runtime dotnet }"
baronfel commented 1 year ago

While we're triaging this issue, you can try telling the extension where an existing .NET installation is, so that it doesn't keep downloading a new one (which is a bug I think we've already addressed elsewhere): https://github.com/dotnet/vscode-dotnet-runtime/blob/main/Documentation/troubleshooting-runtime.md#manually-installing-net

neolib commented 1 year ago

It does not work for me even after adding the settings in user settings.json:

{
    "security.workspace.trust.untrustedFiles": "open",
    "editor.fontSize": 16,
    "files.trimTrailingWhitespace": true,
    "terminal.integrated.enablePersistentSessions": false,
    "dotnetAcquisitionExtension.existingDotnetPath": [
        {
            "extensionId": "msazurermtools.azurerm-vscode-tools",
            "path": "C:\\Program Files\\dotnet\\dotnet.exe"
        }],
}
m-bennett commented 1 year ago

I was able to resolve the issue by installing an older version of the C# extension. I had version 2.0.328 installed when I was experiencing the issue, then I rolled back to version 1.26.0 (it's about 1 month old). Now it's working.

baronfel commented 1 year ago

@neolib when you say "It does not work for me even after adding the settings in user settings.json", what output/etc are you seeing that makes you believe that is the case?

neolib commented 1 year ago

The key problem is that it tries to download latest .NET runtime even I have already installed it.

Downloading the .NET Runtime.
Downloading .NET version(s) 7.0.10 ......................................................................................................................... Error!
Failed to download .NET 7.0.10:
.NET installation timed out.

 Error!
.NET Acquisition Failed: Installation failed: Error: .NET installation timed out.
JRJian commented 1 year ago

Reaching the same problem.

JRJian commented 1 year ago

I found a solution, self-test available. In the VS Code setting.json configuration file, add the following configuration:

"dotnetAcquisitionExtension.existingDotnetPath": [
        {"extensionId": "msazurermtools.azurerm-vscode-tools", "path": "/usr/local/share/dotnet/dotnet"},
        {
            "extensionId": "ms-dotnettools.csdevkit",
            "path": "/usr/local/share/dotnet/dotnet"
        },
        {
            "extensionId": "ms-dotnettools.vscodeintellicode-csharp",
            "path": "/usr/local/share/dotnet/dotnet"
        },
        {
            "extensionId": "ms-dotnettools.csharp",
            "path": "/usr/local/share/dotnet/dotnet"
        },
        {
            "extensionId": "ms-dotnettools.vscode-dotnet-runtime",
            "path": "/usr/local/share/dotnet/dotnet"
        }
    ]