2008-08-27 111 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
相關問題