0

When trying to run dotnet restore in the root folder of my project, I get a following error:

C:\Program Files\dotnet\sdk\7.0.100\NuGet.targets(676,5): error : Unable to obtain lock file access on 'C:\Users\user\AppData\Local\Temp\NuGetScratch\lock' fo
r operations on 'C:\Users\user\AppData\Roaming\NuGet\NuGet.Config'. This may mean that a different user or administrator is holding this lock and that this pr
rashed and left an inaccessible lock file, in this case removing the file 'C:\Users\user\AppData\Local\Temp\NuGetScratch\lock' will allow NuGet to continue. [ 
C:\Users\user\Documents\Kurs C#\FirstProject\FirstProject\FirstProject.csproj]

None of the solutions I've found in the Microsoft docs work. I've managed to find a possible solution here: Dotnet commands fail when restoring Nuget packages in shell script However, how exactly am I supposed to change these permissions?

Mark Cilia Vincenti
  • 1,410
  • 8
  • 25
user9507446
  • 333
  • 1
  • 3
  • 14
  • 4
    Did you try removing the file it tells you to in the error? – Mark Cilia Vincenti Dec 11 '22 at 14:50
  • this file does not exist, and it's not visible even if I change visibility settings for hidden folders and files – user9507446 Dec 11 '22 at 16:04
  • I know this sound stupid, but did you try restarting your computer? File locks can be acquired in a myriad of ways and often they just... go away when you reboot. – AceGambit Dec 11 '22 at 16:29
  • This may help to find who is locking that file, after finding the guilty process you could terminate it and retry to dotnet restore (https://superuser.com/questions/117902/find-out-which-process-is-locking-a-file-or-folder-in-windows) – Ramin Rahimzada Dec 11 '22 at 18:57

0 Answers0