`dotnet build` and `dotnet restore` hangs forever without any error

Viewed 2087

I installed VS2019 with .NET5 SDK on Windows 10. Today it stops working. VS2019 cannot build any .NET project, without showing any error.

I tried to run dotnet build and dotnet restore. It hangs forever without any error. Screenshot: dotnet restore hangs forever without any error

Earlier today my C drive was full. I moved the C:\Users\<user>\.nuget directory to D:\Temp\.nuget, and created a junction point mklink /J C:\Users\<user>\.nuget D:\Temp\.nuget. After I resized my C drive, I moved that directory back. This may be the cause of problem.

I tried to uninstall my .NET 5 SDK, but it does not allow me to do so. Screenshot: .NET 5 SDK was installed with VS2019

I tried to reinstall VS2019 with manually cleanup everything. The problem remains.

Is there anything that I can do before reinstall OS? Thank you.

1 Answers

If you want to move NuGet's global packages folder to a different location/drive, NuGet has built-in support, so no need to use a junction: https://docs.microsoft.com/en-us/nuget/reference/nuget-config-file

So, edit your %appdata%\NuGet\nuget.config file, so it looks something like this:

<configuration>
  <config>
    <add key="globalPackagesFolder" value="d:\Temp\.nuget" />
  </config>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>
Related