mu88
mu88

Reputation: 5384

How to determine Visual Studio version with C#

I'm trying to figure out a reliable, future-proof way to determine the installed Visual Studio versions using C#.

My first idea was to use the registry. But on my PC, I found several keys being named VisualStudio, but not belonging to a complete installation. For example, I've installed VS 2019 and VS Build Tools 2017 - but within the registry, I'm finding 14.0, 15.0, 16.0, 16.1, etc.

Is there any Visual-Studio-API that might could be used?

The deeper meaning of my question is that I have to make the following call supporting multiple versions of VS: var developmentToolsEnvironment = (DTE)Marshal.GetActiveObject("VisualStudio.DTE.15.0");

Upvotes: 2

Views: 1463

Answers (1)

Sergey Vlasov
Sergey Vlasov

Reputation: 27890

You can use Visual Studio setup configuration API for discovering instances of Visual Studio 2017 and newer: Visual Studio Setup Configuration Samples.

Upvotes: 1

Related Questions