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

落花浮王杯 提交于 2019-12-19 03:37:21

问题


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:


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.



来源:https://stackoverflow.com/questions/42779306/programmatically-finding-the-vs2017-most-recently-used-mru-solutions-and-proje

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!