If you register the Microsoft.Build.Framework.dll in the MSBuild folder that's bundled with your version of VS into the Global Assembly Cache does that fix the error?
So if you had 64-bit VS Community 2022 the path containing this assembly is C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin
If you open "Developer Command Prompt for VS 2022", then run "cd C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin"
Then run "gacutil /i Microsoft.Build.Framework.dll"
If you have a different VS installation you'd need to update the path above.