XperiAndri
XperiAndri

Reputation: 1208

How to retrieve a list of installed target framework versions from within visual studio extension?

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.

Upvotes: 1

Views: 713

Answers (2)

cnom
cnom

Reputation: 3241

If you are searching for net core and net5.0 and later:

dotnet --list-sdks

you will get a list like this: enter image description here

Upvotes: 0

Carlos Quintero
Carlos Quintero

Reputation: 4414

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

Upvotes: 1

Related Questions