So I'm back from a nice Christmas break - and completely stymied. When I try to build my Visual Studio 2022 solution I get this message:
Build (web): Could not load file or assembly 'Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I also get this in VS 2019 too. My website is ASP.NET webforms - I've got two other MVC websites which build and run perfectly. Here is the relevant section of my web.config file:
<compilation debug="true" strict="true" explicit="true" batch="false" targetFramework="4.7.2">
<assemblies>
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Printing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
I've just spent 3 hours reading through blogs like this StackOverflow one:
Could not load file or assembly 'Microsoft.Build.Framework'(VS 2017)
I've tried restarting Visual Studio, and even turning my computer off and on again. I've commented out the assembly lines in the web.config file shown above. I went into Nuget package manager and added Microsoft.Build.Framework to see if this would help (it didn't).
Here's what the project references look like:
I've had this sort of problem on numerous other occasions, and usually sorted it fairly quickly - but not this time. I know little about building projects - I just want Visual Studio to do it all for me!
Can any kind person help please?