Programmatically finding the VS2017 Most Recently Used (MRU) solutions and projects
Asked Answered
P

1

5

I know that Visual Studio 2017 now supports no-registry, side-by-side installations of all SKUs (Enterprise, Professional and Community) explanations here.

We need to access the list of VS2017 Most Recently Used (MRU) solutions and projects.

For previous VS2017 version we used to query the registry for that.

  • This registry-query code is still working fine when it is running from inside the VS2017 devenv process,
  • but it is not working anymore when it is executed in a standalone/custom process (I mean a process that is not VS2017 devenv process) and this is what we need to do.

Ideally this could be done from the VS setup API but I cannot find any sample code.

Else we can still rely on the RegLoadAppKey() function as explained in this VS 2017 breaking change article (any code is welcome)

Or maybe there is another API to do that?

Thanks for your help,

Perish answered 14/3, 2017 at 6:40 Comment(0)
P
7

The recommended way to access VS 2017 settings is to use the External Settings Manager:

ExternalSettingsManager ext = ExternalSettingsManager.CreateForApplication(@"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe");
SettingsStore store = ext.GetReadOnlySettingsStore(SettingsScope.UserSettings);
foreach (string name in store.GetPropertyNames(@"MRUItems\{a9c4a31f-f9cb-47a9-abc0-49ce82d0b3ac}\Items"))
{
    string value = store.GetString(@"MRUItems\{a9c4a31f-f9cb-47a9-abc0-49ce82d0b3ac}\Items", name);
    Console.WriteLine("Property name: {0}, value: {1}", name, value);
}

To use the External Settings Manager you need to add a reference to Microsoft.VisualStudio.Settings.15.0.dll to your project.

Petal answered 15/3, 2017 at 19:34 Comment(1)
Thanks very much Radames for this code and response.Perish

© 2022 - 2024 — McMap. All rights reserved.