Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit d66577b

Browse files
committed
Use GitHub.TeamFoundation.15 in VS 2017 and 2019
We can use the GitHub.TeamFoundation.15 MEF assembly in both Visual Studio 2017 and 2019.
1 parent e880b01 commit d66577b

File tree

9 files changed

+13
-511
lines changed

9 files changed

+13
-511
lines changed

GitHubVS.sln

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.TeamFoundation.UnitT
125125
EndProject
126126
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.VisualStudio.UnitTests", "test\GitHub.VisualStudio.UnitTests\GitHub.VisualStudio.UnitTests.csproj", "{8B14F90B-0781-465D-AB94-19C8C56E3A94}"
127127
EndProject
128-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.TeamFoundation.16", "src\GitHub.TeamFoundation.16\GitHub.TeamFoundation.16.csproj", "{F074E95F-A9A0-403F-8633-D112582B8A70}"
129-
EndProject
130128
Global
131129
GlobalSection(SolutionConfigurationPlatforms) = preSolution
132130
Debug|Any CPU = Debug|Any CPU
@@ -506,16 +504,6 @@ Global
506504
{8B14F90B-0781-465D-AB94-19C8C56E3A94}.Release|Any CPU.Build.0 = Release|Any CPU
507505
{8B14F90B-0781-465D-AB94-19C8C56E3A94}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
508506
{8B14F90B-0781-465D-AB94-19C8C56E3A94}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
509-
{F074E95F-A9A0-403F-8633-D112582B8A70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
510-
{F074E95F-A9A0-403F-8633-D112582B8A70}.Debug|Any CPU.Build.0 = Debug|Any CPU
511-
{F074E95F-A9A0-403F-8633-D112582B8A70}.DebugCodeAnalysis|Any CPU.ActiveCfg = DebugCodeAnalysis|Any CPU
512-
{F074E95F-A9A0-403F-8633-D112582B8A70}.DebugCodeAnalysis|Any CPU.Build.0 = DebugCodeAnalysis|Any CPU
513-
{F074E95F-A9A0-403F-8633-D112582B8A70}.DebugWithoutVsix|Any CPU.ActiveCfg = DebugCodeAnalysis|Any CPU
514-
{F074E95F-A9A0-403F-8633-D112582B8A70}.DebugWithoutVsix|Any CPU.Build.0 = DebugCodeAnalysis|Any CPU
515-
{F074E95F-A9A0-403F-8633-D112582B8A70}.Release|Any CPU.ActiveCfg = Release|Any CPU
516-
{F074E95F-A9A0-403F-8633-D112582B8A70}.Release|Any CPU.Build.0 = Release|Any CPU
517-
{F074E95F-A9A0-403F-8633-D112582B8A70}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
518-
{F074E95F-A9A0-403F-8633-D112582B8A70}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
519507
EndGlobalSection
520508
GlobalSection(SolutionProperties) = preSolution
521509
HideSolutionNode = FALSE

src/GitHub.TeamFoundation.15/RegistryHelper.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
using System.Diagnostics;
44
using System.Globalization;
55
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
86
using GitHub.Logging;
97
using GitHub.Models;
108
using GitHub.Services;
@@ -16,10 +14,11 @@ namespace GitHub.TeamFoundation
1614
internal class RegistryHelper
1715
{
1816
static readonly ILogger log = LogManager.ForContext<RegistryHelper>();
19-
const string TEGitKey = @"Software\Microsoft\VisualStudio\15.0\TeamFoundation\GitSourceControl";
17+
2018
static RegistryKey OpenGitKey(string path)
2119
{
22-
return Microsoft.Win32.Registry.CurrentUser.OpenSubKey(TEGitKey + "\\" + path, true);
20+
var keyName = $"Software\\Microsoft\\VisualStudio\\{MajorVersion}.0\\TeamFoundation\\GitSourceControl\\{path}";
21+
return Registry.CurrentUser.OpenSubKey(keyName, true);
2322
}
2423

2524
internal static IEnumerable<ILocalRepositoryModel> PokeTheRegistryForRepositoryList()
@@ -56,23 +55,24 @@ internal static string PokeTheRegistryForLocalClonePath()
5655
}
5756
}
5857

59-
const string NewProjectDialogKeyPath = @"Software\Microsoft\VisualStudio\15.0\NewProjectDialog";
6058
const string MRUKeyPath = "MRUSettingsLocalProjectLocationEntries";
6159
internal static string SetDefaultProjectPath(string path)
6260
{
61+
var newProjectDialogKeyPath = $"Software\\Microsoft\\VisualStudio\\{MajorVersion}.0\\NewProjectDialog";
62+
6363
var old = String.Empty;
6464
try
6565
{
66-
var newProjectKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(NewProjectDialogKeyPath, true) ??
67-
Microsoft.Win32.Registry.CurrentUser.CreateSubKey(NewProjectDialogKeyPath);
66+
var newProjectKey = Registry.CurrentUser.OpenSubKey(newProjectDialogKeyPath, true) ??
67+
Registry.CurrentUser.CreateSubKey(newProjectDialogKeyPath);
6868

6969
if (newProjectKey == null)
7070
{
7171
throw new GitHubLogicException(
7272
string.Format(
7373
CultureInfo.CurrentCulture,
7474
"Could not open or create registry key '{0}'",
75-
NewProjectDialogKeyPath));
75+
newProjectDialogKeyPath));
7676
}
7777

7878
using (newProjectKey)
@@ -120,5 +120,8 @@ internal static string SetDefaultProjectPath(string path)
120120
}
121121
return old;
122122
}
123+
124+
// Major version number of the current devenv process
125+
static int MajorVersion => Process.GetCurrentProcess().MainModule.FileVersionInfo.FileMajorPart;
123126
}
124127
}

0 commit comments

Comments
 (0)