When I load certain old project into MSBuildWorkspace I get the Diagnostic error:
Msbuild failed when processing the file "...SomeProj.csproj" with message: The tools version "Current" is unrecognized. Available tools versions are "2.0", "3.5", "4.0".
and empty list of MetadataReferences.
(The project opens correctly in the VS 2022 on the same PC.)
But if I edit the ...SomeProj.csproj file in the notepad and remove the "ToolsVersion" attribute, then the project with MetadataReferences loads correctly into the MSBuildWorkspace. How to make the ToolsVersion attribute be ignored programmatically without modifying the csproj file itself?
I have clean windows with installed VS 2022. If I additionally install the build tools 2019, the issue stops reproducing, but there must be a way to avoid additional installations since the project opens correctly in the VS 2022.