phmonte / Buildalyzer

A utility to perform design-time builds of .NET projects without having to think too hard about it.
MIT License
589 stars 92 forks source link

Buildalizer chooses MSBuild without .NET components #165

Open Inok opened 3 years ago

Inok commented 3 years ago

I have the following Visual Studio installations:

Buildalizer chooses VS Build Tools 2019 installation to run msbuild. Since it has no .NET components, the build fails. Installing .NET components to that installation fixes the problem. But maybe it's possible to choose the appropriate installation by a Buildalizer itself?

daveaglick commented 3 years ago

What an interesting scenario. It never occurred to me this might be a problem, but it makes total sense. I guess the challenge is knowing which one to pick - I.e. if it were reversed and the VS Build Tools had the .NET components but the VS install only had C++, how would we know?

Inok commented 3 years ago

vswhere allows to search for VS installation with required components: https://github.com/microsoft/vswhere I guess it can be used to find appropriate installation. It's a part of VS Installer, so it's possible to call it from there. Also, it looks like there is an option to distribute vswhere as a part of Buildalizer.

birojnayak commented 2 years ago

@daveaglick @Inok is there a plan to fix this issue ? we are using this project for building another tool and would be happy to contribute and fix if not fixed yet....

smhmhmd commented 2 years ago

How about https://github.com/microsoft/MSBuildLocator

What is Locator for? MSBuild offers a .NET API surface that allows you to evaluate and build MSBuild projects from an application.

Loading MSBuild from Visual Studio also ensures that your application gets the same view of projects as MSBuild.exe, dotnet build, or Visual Studio, including bug fixes, feature additions, and performance improvements that may come from a newer MSBuild release.