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

Respect DOTNET_ROOT #225

Closed Forgind closed 10 months ago

Forgind commented 11 months ago

Per https://github.com/dotnet/format/issues/1925#issuecomment-1664382538 (see that issue for more context)

YuliiaKovalova commented 11 months ago

@rainersigwald , this looks good to me. Do you have any comments?

rainersigwald commented 11 months ago

DOTNET_ROOT seems analogous to DiscoveryOptions.DeveloperConsole. Should we instead extend that concept and codepath to respect it (as well as the VS environment variables)?

Forgind commented 11 months ago

DOTNET_ROOT seems analogous to DiscoveryOptions.DeveloperConsole. Should we instead extend that concept and codepath to respect it (as well as the VS environment variables)?

There are definitely some similarities. I don't think there's a lot of overlap, though, which would make it tricky to try to reuse too much code—DiscoveryOptions.DeveloperConsole is specifically intended to be for NetFx users of VS developer command prompts, a very specific scenario. Of note, the environment variables it checks for there (VSINSTALLDIR, VSCMD_VER, and VisualStudioVersion) are rather VS-specific and not relevant to the DotNetSdkLocationHelper.

So I guess I'm not entirely clear on what concrete changes you're proposing? Though as I was rooting (hehe) around, I did notice there's also a DOTNET_ROOT(x86), so I should probably take that into account as well even though no one (to my knowledge) has specifically requested that yet.

YuliiaKovalova commented 10 months ago

@baronfel , @rainersigwald any blockers for this one?