[Unity Stepping Pit Series] Configuring the VScode environment Downloading the.NET Runtime Failed to download.NET 7.0.9installation timed out

1. Problem description

When using Unity to configure the VScode development environment recently, the following situations always occur. (Many friends have already installed the .net environment locally. PS: Maybe various versions of .net 6.0 - .net 8.0 have been installed, but they will automatically download the latest version of .net)
insert image description here

Downloading the .NET Runtime.
Downloading .NET version(s) 7.0.9 .................................................................................................................. Error!
Failed to download .NET 7.0.9:
.NET installation timed out.
Error!
.NET Acquisition Failed: Installation failed: Error: .NET installation timed out.

The root cause is that our VScode C# extension plug-in does not detect the local .net environment, which leads to automatic download of the latest version of .net runtime

2. Solution

1. We have downloaded and installed the corresponding version of .net locally
2. Open the Extensions bar of VScode
3. Find .NET Install Tool for Extension Authors according to the process below and open the corresponding Extension settings
insert image description here
4. Find Edit in settings.json button
insert image description here
5. After opening the Json file, the reason for the problem is that there is no corresponding path configuration in the original dotnetPath (as shown in the figure below)
insert image description here
6. At this point we need to add the path configuration of our own dotnet environment variable ( As shown in the figure below PS: The path of the dotnet environment variable normally installed by default is as shown in the figure below. If you have adjusted it yourself, you need to find the correct path.) The following
insert image description here
is the corresponding path configuration Json

{
    
    
    "dotnetAcquisitionExtension.existingDotnetPath": [
        {
    
    
            "extensionId": "ms-dotnettools.csharp",
            "path": "C:\\Program Files\\dotnet\\dotnet.exe"
          }
    ]
}

7. Close VScode after saving the file, open it again and you will find that the problem is solved! (dotnet runtime is no longer automatically downloaded)
insert image description here

3. References

This problem is estimated to be a bug in the new version of the VScode C# plug-in or the .NET Install Tool for Extension Authors plug-in, which only appeared recently, so there are relatively few related information and solutions on the Internet. So in the end, I found the problem solved by the corresponding answer given by the official in the past few days under the official GitHub of dotnet

  1. dotnet/vscode-csharp Disable .NET Runtime auto-downloading #6029
  2. dotnet/vscode-csharp Why do you always fail to donwload with new version 2.0 #6004
  3. dotnet/vscode-csharp New version tries to download .NET 7 (even though it’s already installed) and fails #6009

Finally, I hope this article can help you solve the problem, thank you for watching!

Guess you like

Origin blog.csdn.net/JavaD0g/article/details/132127940