0

I want to retrieve a list of installed target framework versions (including profiles) from within visual studio extension.

Does anybody know how to do this.

Actually this is a list which is displayed in New Project dialog window in framework version combobox.

Andrii
  • 1,081
  • 1
  • 11
  • 24

1 Answers1

0

This is called "Framework Multi Targeting". There is a SVsFrameworkMultiTargeting service that provides the IVsFrameworkMultiTargeting and IVsFrameworkMultiTargeting2 interfaces. And there is the GetSupportedFrameworks method.

From a package, you can use the following code and then iterate the array of returned strings, where each string contains the Framework + Version + profile:

IVsFrameworkMultiTargeting frameworkMultiTargeting;
Array prgSupportedFrameworks;

frameworkMultiTargeting = base.GetService(typeof(SVsFrameworkMultiTargeting)) as IVsFrameworkMultiTargeting;

frameworkMultiTargeting.GetSupportedFrameworks(out prgSupportedFrameworks);
Carlos Quintero
  • 4,300
  • 1
  • 11
  • 18
  • Is a way to retrieve the target frameworks from a console app as well and how can this be done? – rene_r May 23 '17 at 17:39
  • From a console you can get an EnvDTE.DTE instance, which implements Microsoft.VisualStudio.OLE.Interop.IServiceProvider, so you can get services: https://www.mztools.com/Articles/2007/MZ2007015.aspx – Carlos Quintero May 26 '17 at 12:51