Browse Source

Lookup Mono SDK path on Windows registry.

pull/955/head
Joao Matos 9 years ago
parent
commit
45232ec8a2
  1. 29
      src/Core/Toolchains/ManagedToolchain.cs

29
src/Core/Toolchains/ManagedToolchain.cs

@ -2,15 +2,42 @@ @@ -2,15 +2,42 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Win32;
namespace CppSharp
{
public static class ManagedToolchain
{
public static string FindMonoPath()
public static string ReadMonoPathFromWindowsRegistry(bool prefer64bits = false)
{
using (var baseKey = RegistryKey.OpenBaseKey (RegistryHive.LocalMachine,
prefer64bits ? RegistryView.Registry64 : RegistryView.Registry32))
{
if (baseKey == null)
return null;
using (var subKey = baseKey.OpenSubKey (@"SOFTWARE\Mono"))
{
if (subKey == null)
return null;
return (string)subKey.GetValue ("SdkInstallRoot", "");
}
}
}
public static string FindMonoPath(bool prefer64bits = false)
{
if (Platform.IsWindows)
{
// Try to lookup the Mono SDK path from registry.
string path = ReadMonoPathFromWindowsRegistry(prefer64bits);
if (!string.IsNullOrEmpty(path))
return path;
// If that fails, then lets try a default location.
return @"C:\Program Files (x86)\Mono";
}
else if (Platform.IsMacOS)
return "/Library/Frameworks/Mono.framework/Versions/Current";
else

Loading…
Cancel
Save