Skip to content

Commit

Permalink
Support for VS2017 (thanks to @bneidhold) (fixes #88 and #89)
Browse files Browse the repository at this point in the history
  • Loading branch information
thoemmi committed Mar 12, 2017
1 parent a7e63f5 commit e7f34e9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Solutionizer/Commands/SaveSolutionCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ private void WriteHeader(TextWriter writer) {
writer.WriteLine("Microsoft Visual Studio Solution File, Format Version 14.00");
writer.WriteLine("# Visual Studio 2015");
break;
case VisualStudioVersion.VS2017:
writer.WriteLine("Microsoft Visual Studio Solution File, Format Version 14.00");
writer.WriteLine("# Visual Studio 15");
break;
default:
throw new ArgumentOutOfRangeException();
}
Expand Down
27 changes: 22 additions & 5 deletions Solutionizer/Helper/VisualStudioHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
namespace Solutionizer.Helper {
public static class VisualStudioHelper {
public static VisualStudioVersion DetectVersion() {
using (var key = Registry.ClassesRoot.OpenSubKey("VisualStudio.DTE.15.0")) {
if (key != null) {
return VisualStudioVersion.VS2017;
}
}
using (var key = Registry.ClassesRoot.OpenSubKey("VisualStudio.DTE.14.0")) {
if (key != null) {
return VisualStudioVersion.VS2015;
Expand All @@ -32,6 +37,8 @@ private static string GetVersionKey(VisualStudioVersion visualStudioVersion) {
return "12.0";
case VisualStudioVersion.VS2015:
return "14.0";
case VisualStudioVersion.VS2017:
return "15.0";
}
return "10.0";
}
Expand Down Expand Up @@ -60,11 +67,21 @@ public static string GetDefaultProjectsLocation(VisualStudioVersion visualStudio
}

public static string GetVisualStudioExecutable(VisualStudioVersion visualStudioVersion) {
var regPath = String.Format(@"Software\Microsoft\VisualStudio\{0}", GetVersionKey(visualStudioVersion));
using (var hiveKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
using (var key = hiveKey.OpenSubKey(regPath)) {
var installPath = key.GetValue("InstallDir") as string;
return Path.Combine(installPath, "devenv.exe");
using (var hiveKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) {
if (visualStudioVersion == VisualStudioVersion.VS2017) {
//TODO maybe use https://www.nuget.org/packages/Microsoft.VisualStudio.Setup.Configuration.Interop/ to detect multiple parallel installed VS2017 instances
var regPath = @"Software\WOW6432Node\Microsoft\VisualStudio\SxS\VS7";
using (var key = hiveKey.OpenSubKey(regPath)) {
var installPath = key.GetValue("15.0") as string;
return Path.Combine(installPath, @"Common7\IDE\devenv.exe");
}
} else {
var regPath = String.Format(@"Software\Microsoft\VisualStudio\{0}", GetVersionKey(visualStudioVersion));
using (var key = hiveKey.OpenSubKey(regPath)) {
var installPath = key.GetValue("InstallDir") as string;
return Path.Combine(installPath, "devenv.exe");
}
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Solutionizer/Services/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ public enum VisualStudioVersion {
VS2010,
VS2012,
VS2013,
VS2015
VS2015,
VS2017,
}
// ReSharper restore InconsistentNaming

Expand Down
3 changes: 3 additions & 0 deletions Solutionizer/Views/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<DataTrigger Binding="{Binding}" Value="VS2015">
<Setter TargetName="PART_Text" Property="Text" Value="Visual Studio 2015" />
</DataTrigger>
<DataTrigger Binding="{Binding}" Value="VS2017">
<Setter TargetName="PART_Text" Property="Text" Value="Visual Studio 2017" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</Grid.Resources>
Expand Down

0 comments on commit e7f34e9

Please sign in to comment.