以编程方式找到VS2017最近使用(MRU)解决方案和项目 [英] Programmatically finding the VS2017 Most Recently Used (MRU) solutions and projects

查看:105
本文介绍了以编程方式找到VS2017最近使用(MRU)解决方案和项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Visual Studio 2017现在支持所有SKU(Enterprise,Professional和Community)解释的无注册并行安装

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

我们需要访问VS2017最近使用(MRU)解决方案和项目的列表.

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

对于以前的VS2017版本,我们曾经查询过注册表.

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

  • 从VS2017 devenv进程内部运行时,此注册表查询代码仍然可以正常工作
  • 但在独立/自定义流程(我的意思是不是VS2017 devenv流程)中执行时,它不再起作用.这是我们需要做的.

理想情况下,这可以通过 VS安装程序API 完成,但是我找不到任何示例代码.

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)

或者也许还有另一个API可以做到这一点?

Or maybe there is another API to do that?

感谢您的帮助,

推荐答案

访问VS 2017设置的推荐方法是使用

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

要使用外部设置管理器,您需要在项目中添加对Microsoft.VisualStudio.Settings.15.0.dll的引用.

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

这篇关于以编程方式找到VS2017最近使用(MRU)解决方案和项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆