Programmatically finding the VS2017 Most Recently

2019-05-11 15:57发布

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,

1条回答
疯言疯语
2楼-- · 2019-05-11 16:30

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.

查看更多
登录 后发表回答