microsoft / MSBuildLocator

An API to locate MSBuild assemblies from an installed Visual Studio location. Use this to ensure that calling the MSBuild API will use the same toolset that a build from Visual Studio or msbuild.exe would.
Other
212 stars 83 forks source link

MSBuildLocator doesn't work with multiple level SDK resolution logic for NET 6 SDK. #274

Closed lifengl closed 4 months ago

lifengl commented 4 months ago

Repro

1, Install NET 7/8 SDK to the machine level 2, Download zip of NET 6 SDK, unzip to a private folder 3, set dotnet path of NET 6 SDK to the front of PATH environment 4, use dotnet --info all SDKs/Runtimes will be listed 5, use MSBuildLocator in this case, it would not resolve NET 7/8 SDKs

Note:

  1. this can be controlled by "DOTNET_MULTILEVEL_LOOKUP" environment variable
  2. this behavior is removed from NET 7 and beyond, so this is narrow to the problem when the local installation is older than NET 7.
YuliiaKovalova commented 4 months ago

Hi @lifengl,

We have discussed and agreed to push back on this one, since hostfxr api doesn't provide a way to request MLL and we are moving towards the end of net6 support. cc: @baronfel