简体   繁体   English

以编程方式查找VS2017最近使用(MRU)解决方案和项目

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

I know that Visual Studio 2017 now supports no-registry, side-by-side installations of all SKUs (Enterprise, Professional and Community) explanations here . 我知道的Visual Studio 2017年现在支持无注册,并排侧所有SKU(企业版,专业版和社区)解释安装在这里

We need to access the list of VS2017 Most Recently Used (MRU) solutions and projects. 我们需要访问VS2017最近使用(MRU)解决方案和项目的列表。

For previous VS2017 version we used to query the registry for that. 对于以前的VS2017版本,我们用于查询注册表。

  • This registry-query code is still working fine when it is running from inside the VS2017 devenv process, 从VS2017 devenv进程内部运行时,此注册表查询代码仍然正常工作,
  • 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 . 但是当它在独立/自定义过程中执行时它不再起作用(我的意思是一个不是VS2017 devenv过程的过程) ,这就是我们需要做的

Ideally this could be done from the VS setup API but I cannot find any sample code. 理想情况下,这可以从VS setup API完成,但我找不到任何示例代码。

Else we can still rely on the RegLoadAppKey() function as explained in this VS 2017 breaking change article (any code is welcome) 另外,我们仍然可以依赖RegLoadAppKey()函数,如本VS 2017 破坏性 更改文章中所述 (欢迎任何代码)

Or maybe there is another API to do that? 或者可能还有其他API可以做到这一点?

Thanks for your help, 谢谢你的帮助,

The recommended way to access VS 2017 settings is to use the External Settings Manager : 访问VS 2017设置的推荐方法是使用外部设置管理器

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. 要使用外部设置管理器,您需要将Microsoft.VisualStudio.Settings.15.0.dll的引用添加到项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM