Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect the Visual Studio version inside a VSPackage

How can I check/detect which Visual Studio version is running under my VSPackage?

I cannot get from the registry because the computer could have several versions installed, so I guess there is an API that is able to get it.

Anybody knows how to get it from a managed Visual Studio package using C#?

like image 241
Daniel Peñalba Avatar asked Jun 18 '12 12:06

Daniel Peñalba


People also ask

How do I know which version of Visual Studio I have?

On macOS, go to Code > About Visual Studio Code. On Windows and Linux, go to Help > About. The VS Code version is the first Version number listed and has the version format 'major.

How do I know which version of Visual Studio 2019 I have?

Click on Help > About Microsoft Visual Studio . You will see the version number and the update you have installed.


1 Answers

You could try to get version via automation DTE object. In MPF you could get it in this way:

EnvDTE.DTE dte = (EnvDTE.DTE)Package.GetGlobalService(typeof(EnvDTE.DTE));

There are some other related things to retrieve DTE object - via Project.DTE, also read this thread if you're getting null for DTE.

Then you can get the version by using DTE.Version property.

Also useful information could be found on Carlos Quintero (VS addin ninja) website HOWTO: Detect installed Visual Studio editions, packages or service packs

like image 198
Dmitry Pavlov Avatar answered Sep 24 '22 18:09

Dmitry Pavlov