02.vs插件 获取项目和解决方案路径
获取项目 解决方案路径
/// <summary>
/// 获取并设置项目和解决方案绝对路径
/// </summary>
/// <returns></returns>
protected void GetSetPath()
{
var dte2 = Package.GetGlobalService(typeof(DTE)) as DTE2;
var solution = dte2.Solution;
//var projects = solution.Projects; var projects = (UIHierarchyItem[])dte2?.ToolWindows.SolutionExplorer.SelectedItems;
var project = projects[].Object as Project; var SolutionName = Path.GetFileName(solution.FullName);//解决方案名称
var SolutionDir = Path.GetDirectoryName(solution.FullName);//解决方案路径
var ProjectName = Path.GetFileName(project.FullName);//项目名称
var ProjectDir = Path.GetDirectoryName(project.FullName);//项目路径
}
var dte2 = this.Dte2;
var solution = dte2.Solution;
//var projects = solution.Projects;
var projects = (UIHierarchyItem[])dte2?.ToolWindows.SolutionExplorer.SelectedItems;
var project = projects[].Object as Project;
//获取项目所有引用
var vsproject = project.Object as VSLangProj.VSProject;
foreach (VSLangProj.Reference reference in vsproject.References)
{
if (reference.SourceProject == null)
{
// This is an assembly reference
var fullName = GetFullName(reference);
var assemblyName = new AssemblyName(fullName);
}
else
{
// This is a project reference
}
}
this.Parameter.SolutionName = Path.GetFileName(solution.FullName);
this.Parameter.SolutionDir = Path.GetDirectoryName(solution.FullName);
this.Parameter.ProjectName = Path.GetFileName(project.FullName);
this.Parameter.ProjectDir = Path.GetDirectoryName(project.FullName);
弹窗提示
/// <summary>
/// 警告
/// </summary>
/// <param name="body"></param>
protected void ShowMessageBox(string body, string title = "警告")
{
System.Windows.Forms.MessageBox.Show(body, title, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
}
02.vs插件 获取项目和解决方案路径的更多相关文章
- Java获取项目中的路径 分类: Java Game 2014-08-14 10:17 122人阅读 评论(0) 收藏
在项目中经常需要获取某个文件的路径: 在这里提供一些获取路径的方法.. 1.此种方式获取的路径,是当前类所在的路径: UserDAOTest.class.getResource("UserD ...
- springboot获取项目的绝对路径和根目录
springboot获取当前项目路径的地址 System.getProperty("user.dir") 输出目录: G:\outshine\wangsoso //获取class ...
- Python - 超好用的第三方库pathlib,快速获取项目中各种路径
前言 之前曾介绍过Python的os库详细使用方式,具体可看看这篇博文:https://www.cnblogs.com/poloyy/p/12341231.html 博主在学完os库之后,就开始投入使 ...
- python 获取项目的根路径
root_path = os.path.abspath(os.path.dirname(__file__)).split('shippingSchedule')[0] shippingSchedule ...
- String.valueOf(Thread.currentThread().getContextClassLoader().getResource("")) 获取项目的绝对路径(shiro项目中来的八)
一,上代码 String.valueOf(Thread.currentThread().getContextClassLoader().getResource("")) file: ...
- jsp笔记----jsp常用的的获取项目的根路径
<% String path = request.getContextPath(); String basePath = request.getScheme() + "://" ...
- 易宝支付Demo,生产中封装成简洁的代付接口,不用request如何获取项目运行时的真实路径
最近项目在做融360引流,涉及到了易宝支付的代扣和代付.易宝官方给出的demo只能简单运行,而且都是通过form表单的形式提交,返回XML格式.同时接口代码都写在了JSP中看起来不友好.项目在生成中想 ...
- jdk1.8中获取项目绝对路径和项目路径
request.getSession().getServletContext().getRealPath("") 获取项目的绝对路径,含着项目的名称. request.getSe ...
- java获取项目路径,url路径
我的web项目名iamgeModel. 工作空间在D盘 先获取url相关: 需要是HttpServletRequest request; 获取IP: request.getServerName() / ...
随机推荐
- Spring Boot + kkFileView-2.1.2 实现文档在线预览
1. 下载kkFileview:https://gitee.com/kekingcn/file-online-preview/releases 2. 启动服务 进入 bin 目录,双击 startup ...
- Android代号、版本及API级别之间的对应关系
参考链接:Codenames, Tags, and Build Numbers | Android Open Source Project
- 转载:ASP.NET Core 在 JSON 文件中配置依赖注入
在以前的 ASP.NET 4+ (MVC,Web Api,Owin,SingalR等)时候,都是提供了专有的接口以供使用第三方的依赖注入组件,比如我们常用的会使用 Autofac.Untiy.Stri ...
- vba增删改查数据库
你在EXCEL中增加一个列名为ID,后在VBA中写以下代码,并引用Microsoft ActiveX Data Objects 2.8后执行Public Sub 写入SQL2008()Dim cnn ...
- EXCEL表格链接SQLSEVER数据库
Sub 数据库连接() Set Cnn = CreateObject("ADODB.Connection") Set rs = CreateObject(" ...
- 0916CSP-S模拟测试赛后总结
40分-rank35. 不想找借口.实力不行. 赛时状态没出什么大问题.就是实力太弱了. 天皇又AK了.去问了一下,他说全是简单题…… 后来发现一些人用非正解AC了. 但是天皇题题正解题题首切啊. 还 ...
- python相关软件安装流程图解——Windows下安装Redis以及可视化工具——Redis-x64-3.2.100——redis-desktop-manager-0.9.3.817
https://www.2cto.com/database/201708/666191.html https://github.com/MicrosoftArchive/redis/releases ...
- mysql索引原理深度解析
mysql索引原理深度解析 一.总结 一句话总结: mysql索引是b+树,因为b+树在范围查找.节点查找等方面优化 hash索引,完全平衡二叉树,b树等 1.数据库中最常见的慢查询优化方式是什么? ...
- Http学习(二)
使用首部字段是为了给浏览器和服务器提供报文主体大小.所使用语言.认证信息等 4种首部字段类型 通用首部字段 请求首部字段 响应首部字段 实体首部字段 详细说明: HTTP首部字段类型 通用首部字段: ...
- Linux unzip解压多个文件
假设当前目录下有多个zip文件 data.zip invoices.zip pictures.zip visit.zip, 直接 unzip *.zip 等价于 unzip data.zip invo ...