简体   繁体   中英

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");

您可以使用 Visual Studio 安装配置 API 来发现 Visual Studio 2017 和更高版本的实例: Visual Studio 安装配置示例

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM