VSCode打开c#项目,会自动下载.NET环境,下载不了报超时,详情如下:
ms-dotnettools.csharp tried to install .NET 8.0.11~x64 but that install had already been requested. No downloads or changes were made.
ms-dotnettools.csharp requested to download the .NET Runtime.
Downloading .NET version(s) 8.0.11~x64 ........................................................
Error : (DotnetAcquisitionTimeoutError)
Failed to download .NET 8.0.11~x64:
Command failed: powershell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy unrestricted -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; & 'c:\Users\admin\.vscode\extensions\ms-dotnettools.vscode-dotnet-runtime-2.2.3\dist\install scripts\dotnet-install.ps1' -InstallDir 'c:\Users\admin\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\8.0.11~x64' -Version 8.0.11 -Verbose -Runtime dotnet -Architecture x64 }"
更奇怪的是这个是默认的,设置里面也没有配置项可以去掉这个默认加载的限制(而且其实我是有安装.NET环境的),有点离谱……
去GitHub找了下,发现了这篇文章:https://github.com/dotnet/vscode-dotnet-runtime/blob/main/Documentation/troubleshooting-runtime.md#install-script-timeouts,配置下settings.json
可以解决该问题,配置后重新打开就正常了。
{
"dotnetAcquisitionExtension.existingDotnetPath": [
{
"extensionId": "ms-dotnettools.csharp",
// C:\Program Files\dotnet\dotnet.exe
"path": "C:\\Program Files\\dotnet\\dotnet.exe"
}
]
}
参考:
https://github.com/dotnet/vscode-dotnet-runtime/blob/main/Documentation/troubleshooting-runtime.md#install-script-timeouts
https://github.com/dotnet/vscode-csharp/issues/6004
https://blog.csdn.net/gaozhaoyuyu/article/details/132191630