如何获取 %vsspv_visualstudio_dir% 变量的值? [英] How can I get the value of %vsspv_visualstudio_dir% variable?

查看:26
本文介绍了如何获取 %vsspv_visualstudio_dir% 变量的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VS2015 更新 3

VS2015 Update 3

在我的外部应用程序中,我需要获取 VS2015 的 User project templates locationUser item templates location 设置值.然后我会将我的模板添加到该目录中.

In my external application I need to get the User project templates location and User item templates location settings values for VS2015. Then I will add my templates into that directories.

HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\Profile\AutoSaveFile 参数包含 %vsspv_visualstudio_dir%\settings\CurrentSettings.vssettings 值.

在该文件中,必要的值还包含 %vsspv_visualstudio_dir% 变量:

Inside of that file the necessary values also contains the %vsspv_visualstudio_dir% variable:

<PropertyValue name="ProjectTemplatesLocation">%vsspv_visualstudio_dir%\Templates\ProjectTemplates</PropertyValue>  
<PropertyValue name="ProjectItemTemplatesLocation">%vsspv_visualstudio_dir%\Templates\ItemTemplates</PropertyValue>

如何扩展 %vsspv_visualstudio_dir% 变量?Environment.ExpandEnvironmentVariables(String) 方法无法展开它:

How can I expand the %vsspv_visualstudio_dir% variable? The Environment.ExpandEnvironmentVariables(String) method can't expand it:

var str = Environment.ExpandEnvironmentVariables(
    "%vsspv_visualstudio_dir%"); // I get the same string

推荐答案

当前 VS2015 用户配置文件的项目和项模板文件夹的位置也可以在以下注册表项中找到:

The locations of project and item templates folder for current VS2015 user profile can also be found in the following registry keys:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\UserProjectTemplatesLocation
HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\UserItemTemplatesLocation

这些值不包含任何变量,因此可以按原样使用.

Those values do not contain any variables and so can be used as is.

这篇关于如何获取 %vsspv_visualstudio_dir% 变量的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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