I work with an application where we use a lot of API from Microsoft.Build package. In that package properties I can see path is C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\Microsoft.Build.dll and the version 4.0.0.0
Goal:
I would like to use newer version of build tools without adding references of that build tools to the application. I already encountered Microsoft.Build.Locator which gathers all the information regarding installed build tools on the machine and is able to use choosen version. But it has one disadvantage - it doesn't have fallback mechanism.
For example, I would like to load/use newest available version of build tools and if there is no any newer installed, use this from GAC. I was playing with Microsoft.Build.Locator API and from my undestanding it can locate only build tools in version >= 15.0 I tried to register version from GAC using following method:
MSBuildLocator.RegisterMSBuildPath(new string[] { @"C:\Windows\Microsoft.NET\assembly\GAC_MSIL" });
but I get an exception that build tools with version 15 are not found. I assume this is expected behaviour for Microsoft.Build.Locator package, unless I am doing something wrong.
So in summary, is there something more I can do to achieve described behavior -> Use build tools from GAC unless there is newer version, then use that newer version.