2008-08-27 112 views
68

我经常使用Visual Studio的多个实例,通常在同一个解决方案的不同分支上工作。在Visual Studio IDE中显示解决方案/文件路径

VC6用于在其标题栏中显示当前源文件的完整路径,但Visual Studio 2005似乎没有这样做。这使得它比计算我目前正在查看的解决方案的哪个分支(我知道的最快方法是将鼠标悬停在选项卡上,以便将源文件的路径作为工具提示)稍微笨拙一些。

是否有任何方法可以将完整解决方案或文件路径导入标题栏,或者至少在某处始终可见,以便我可以快速判断哪个分支加载到每个实例中?

回答

24

有没有一种原生的方式来做到这一点,但你可以用宏来实现它。 详细信息在这里完整描述:http://www.helixoft.com/blog/archives/32

你只需要添加一个VB宏到EvironmentEvents宏部分,并重新启动VS.

注意:当您第一次加载VS时,路径不会显示,但只要您更改正在查看的文件即可。可能有办法解决这个问题,但看起来并不是什么大问题。

+0

[文件路径页脚](https://visualstudiogallery.msdn.microsoft.com/d9fc97d4-3b42-4b56-ba47-23f8b81ebd17/)也是一个不错的扩展 – dan 2016-07-31 07:40:30

1

相关备注:作为替代,对于Visual Studio 2005,您可以使用命令文件 - >高级保存选项。该对话框显示当前文件的完整路径,并且您可以复制文本。

17

检查出最新版本VSCommands 2010 Lite。它引入了一个称为友好解决方案名称的功能,您可以将其设置为在Visual Studio主窗口标题中显示解决方案文件路径(或其任何部分)。更多细节:http://vscommands.com/releasenotes/3.6.8.0http://vscommands.com/releasenotes/3.6.9.0

+2

看起来已经略有移动到这里:http://vscommands.squaredinfinity.com/ – ruffin 2012-10-26 19:07:30

+0

vs2013版本:http://visualstudiogallery.msdn.microsoft.com/c6d1c265-7007-405c-a68b-5606af238ece – 2014-07-01 02:42:18

4

2008年,一个稍微好一点的方式来写从上面的接受的答案宏是使用该解决方案的事件,而不是文件的 - 这可以让你随时编辑标题栏,即使你没有选择文件。下面是我的同事和我基于另一个的宏 - 您将需要更改第15-18行,以便从源目录中获取您的分支名称,以便设置。

01 Private timer As System.Threading.Timer 
02 Declare Auto Function SetWindowText Lib "user32" (ByVal hWnd As System.IntPtr, ByVal lpstring As String) As Boolean 
03 
04 Private _branchName As String = String.Empty 
05 Private Sub SolutionEvents_Opened() Handles SolutionEvents.Opened 
06  Try 
07   If timer Is Nothing Then 
08    ' Create timer which refreshes the caption because 
09    ' IDE resets the caption very often 
10    Dim autoEvent As New System.Threading.AutoResetEvent(False) 
11    Dim timerDelegate As System.Threading.TimerCallback = _ 
12     AddressOf tick 
13    timer = New System.Threading.Timer(timerDelegate, autoEvent, 0, 25) 
14   End If 
15   Dim sourceIndex As Integer = DTE.Solution.FullName.IndexOf("\Source") 
16   Dim shortTitle As String = DTE.Solution.FullName.Substring(0, sourceIndex) 
17   Dim lastIndex As Integer = shortTitle.LastIndexOf("\") 
18   _branchName = shortTitle.Substring(lastIndex + 1) 
19   showTitle(_branchName) 
20  Catch ex As Exception 
21 
22  End Try 
23 End Sub 
24 
25 Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing 
26  If Not timer Is Nothing Then 
27   timer.Dispose() 
28  End If 
29 End Sub 
30 
31 
32 ''' <summary>Dispose the timer on IDE shutdown.</summary> 
33 Public Sub DTEEvents_OnBeginShutdown() Handles DTEEvents.OnBeginShutdown 
34  If Not timer Is Nothing Then 
35   timer.Dispose() 
36  End If 
37 End Sub 
38 
39 '''<summary>Called by timer.</summary> 
40 Public Sub tick(ByVal state As Object) 
41  Try 
42   showTitle(_branchName) 
43  Catch ex As System.Exception 
44  End Try 
45 End Sub 
46 
47 '''<summary>Shows the title in main window.</summary> 
48 Private Sub showTitle(ByVal title As String) 
49  SetWindowText(New System.IntPtr(DTE.MainWindow.HWnd), title & " - " & DTE.Name) 
50 End Sub 
+0

谢谢,正是我想要的! – 2011-05-21 21:37:13

2

使用MKLINK命令创建到现有解决方案的链接。就Visual Studio而言,它是关于链接文件的工作,但任何更改都会转到底层的.sln文件。

我这里写了一篇博客条目它...

http://willissoftware.com/?p=72

3

我正在使用VSCommands 10来显示解决方案文件打开的完整路径。现在

Friendly Name: {repo} 
Solution Path Regex: (?<repo>.*) 

我的主标题窗口如下所示:

c:\repositories\acme.marketplace.trunk\Acme.Marketplace.web\Acme.Marketplace.Web.sln 

我可以快速浏览,看到我在树干文件夹或RC文件夹,我的工作,因为我们使用水银(汞),并保持干线,RC,preprod,督促单独的文件夹是这样的:

c:\repositories\acme.marketplace.rc1 
c:\repositories\acme.marketplace.rc2 
c:\repositories\acme.marketplace.trunk 
c:\repositories\acme.marketplace.preprod 
c:\repositories\acme.marketplace.prod 
2

如何自定义Visual Studio的窗口标题

安装Customize Visual Studio Window Title插件。

安装扩展后,可以在菜单中找到设置。

Tools ► Options ► Customize VS Window Title

更多信息

Customize Visual Studio Window Title是一个轻量级扩展到Visual Studio,它允许您更改窗口标题包含一个文件夹树

enter image description here

特点

  • A conf从解决方案/项目文件可配置的最小和最大深度距离
  • 允许使用特殊标签来帮助其他许多可能的场景,其中包括GitMercurialTFS
相关问题