dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.75k stars 1.07k forks source link

Can't install dotnet tools; The process cannot access the file #26381

Open Kvixen opened 2 years ago

Kvixen commented 2 years ago

Describe the bug

dotnet tool install <tool> fails for some tools with the following message:

C:\Program Files\dotnet\sdk\5.0.408\NuGet.targets(131,5): error : The process cannot access the file 'C:\Users\<user>\.nuget\packages\gitversion.tool\5.10.3\tools\netcoreapp3.1\any\gitversion.dll' because it is being used by another process. [C:\Users\<user>\AppData\Local\Temp\4cgahxad.cf1\restore.csproj]


I've tried in total 4 tools; dotneysay - Successfully installed amazon.lambda.tools - Successfully installed GitVersion.Tool - Fails with attached message above and log below upgrade-assistant - Fails for same reason as GitVersion.Tool


The installation always fails on the same task, "RestoreTask", always after the same step, PackageSignatureVerificationLog: PackageIdentity. Here's the snippet from running the installation with -v d;

https://gist.github.com/Kvixen/14394fbb3d14400c777caa21d79b81ad

To Reproduce

Since I've spent a pretty long time searching and only found someone who has reproduced this error, but that's by running multiple dotnet tool list at the same time. This issue can be found here:

15399

I've attached my systeminfo and dotnet info below in-case any reproduction could be done using that information.

For me, of course, I can reproduce this error by running dotnet tool install GitVersion.Tool

Exceptions (if any)

Exception: The process cannot access the file

Full error: C:\Program Files\dotnet\sdk\5.0.408\NuGet.targets(131,5): error : The process cannot access the file 'C:\Users\<user>\.nuget\packages\gitversion.tool\5.10.3\tools\netcoreapp3.1\any\gitversion.dll' because it is being used by another process. [C:\Users\<user>\AppData\Local\Temp\4cgahxad.cf1\restore.csproj]

Further technical details

dotnet --info ``` C:\>dotnet --info .NET SDK (reflecting any global.json): Version: 5.0.408 Commit: da985e2a23 Runtime Environment: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.408\ Host (useful for support): Version: 5.0.17 Commit: 6a98414363 .NET SDKs installed: 5.0.408 [C:\Program Files\dotnet\sdk] NET runtimes installed: Microsoft.AspNetCore.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] ```
systeminfo ``` C:\>systeminfo Host Name: HOSTNAME OS Name: Microsoft Windows 10 Enterprise OS Version: 10.0.19042 N/A Build 19042 OS Manufacturer: Microsoft Corporation OS Configuration: Member Workstation OS Build Type: Multiprocessor Free Registered Owner: Windows User Original Install Date: 2022-02-09, 12:40:28 System Boot Time: 2022-06-29, 16:13:49 System Manufacturer: HP System Model: HP ZBook Studio G5 System Type: x64-based PC Processor(s): 1 Processor(s) Installed. [01]: Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz BIOS Version: HP Q71 Ver. 79.01.00, 2018-11-16 Windows Directory: C:\WINDOWS System Directory: C:\WINDOWS\system32 Boot Device: \Device\HarddiskVolume2 System Locale: sv;Swedish Input Locale: sv;Swedish Time Zone: (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna Total Physical Memory: 16 195 MB Available Physical Memory: 6 891 MB Virtual Memory: Max Size: 29 507 MB Virtual Memory: Available: 15 760 MB Virtual Memory: In Use: 13 747 MB Page File Location(s): C:\pagefile.sys Hotfix(s): 11 Hotfix(s) Installed. [01]: KB5013624 [02]: KB4562830 [03]: KB4570334 [04]: KB4580325 [05]: KB5007401 [06]: KB5013942 [07]: KB5007273 [08]: KB5011352 [09]: KB5011651 [10]: KB5014032 [11]: KB5005260 Network Card(s): 5 NIC(s) Installed. [01]: Intel(R) Wireless-AC 9560 160MHz Connection Name: Wi-Fi Status: Media disconnected [02]: Bluetooth Device (Personal Area Network) Connection Name: Bluetooth Network Connection Status: Media disconnected [03]: Realtek USB GbE Family Controller Connection Name: Ethernet DHCP Enabled: Yes DHCP Server: 138.106.14.37 IP address(es) [01]: 138.106.133.207 [02]: fe80::a1f1:6b5:a723:bfa6 [04]: Hyper-V Virtual Ethernet Adapter Connection Name: vEthernet (Default Switch) DHCP Enabled: No IP address(es) [01]: 172.17.176.1 [02]: fe80::7dba:dfd3:fd38:12f7 [05]: Hyper-V Virtual Ethernet Adapter Connection Name: vEthernet (WSL) DHCP Enabled: No IP address(es) [01]: 172.22.208.1 [02]: fe80::a9ce:8f28:d19a:80e2 Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed. ```
baronfel commented 1 year ago

Can you try to reproduce on 7.0.103 or 7.0.200 - those versions got a patch that should solve some of the file contention.

RuddyOne commented 1 year ago

Also having this issue, did you find a fix?