After upgrading VS to 16.7.2 from 16.6.5, MSBuild stopped working. I've tried to solve this issue for many days now, removing/adding versions and paths from GAC, registry, env path, restarting, uninstalling, installing, old versions and new, and so on, and haven't been able to solve it.
The symptoms right now:
for a brand new class library project in VS2019 (downgraded back to 16.6.5), I'm getting this error on build:
The "NuGet.Build.Tasks.GetRestoreProjectStyleTask" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.Build.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
For the project I'm currently working on (ASP.NET targeting 4.7.2):
The "NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.Build.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
I'm also getting "The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)" for every single reference.