I've been burning a few hours on this problem and have done a lot of searching to figure out what's going on.
I have an app which loads Project files from .csproj files, so it references Microsoft.Build dlls. On one of my computers everything works fine. On another, the app crashes when I try to load a .csproj file.
The exception I'm getting is of type Microsoft.Build.Exceptions.InvalidProjectFileException
with the following message:
The tools version "15.0" is unrecognized. Available tools versions are "14.0", "2.0", "3.5", "4.0".
At first I wasn't sure what was causing the problem so I thought I'd include the .dlls as part of my project. That is, I copied the .dlls to a folder in my project, and referenced those .dlls. But when I run my project the GAC loading preference is biting me, as the output window shows me that a different .dll is being loaded:
Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Build.Framework\v4.0_15.1.0.0__b03f5f7f11d50a3a\Microsoft.Build.Framework.dll'.
So I looked at the .dll being loaded on each machine by navigating to that location and viewing the properties on the .dll.
On the machine that does work the .dll has the version 15.1.1015. On the machine that does not work the .dll has the version 15.3.409
I haven't found people talking about this exact problem, but I have seen people talk about having issues after having upgraded to Visual Studio 15.3. Sure enough, the computer that does not work has Visual Studio 15.3.5, while the computer that does work has Visual Studio 15.2.
To try to address this, I removed 15.3 from the GAC using steps outlined here:
Could not load type 'Microsoft.Build.Framework.SdkReference' on project open in VS 2017 U1 (15.3)
Alas, even after this change, I am still encountering the same problem, so changing the GAC to point to an earlier Microsoft.Build.Framework.dll still didn't fix it (maybe because other files in the Microsoft.Build family are being GAC'ed in at 15.3?). I did verify that the version loaded by the GAC is now 15.1.
Is there another workaround or fix I could apply to solve this problem?