private static string GetCscPath() { string toolPath; switch (Platform.BuildPlatform.Target) { case TargetPlatform.Linux: case TargetPlatform.Mac: { // Use csc from Mono toolPath = UnixPlatform.Which("csc"); if (toolPath != null) { return(toolPath); } break; } case TargetPlatform.Windows: { if (CheckMsBuildPathFromRegistry("Microsoft\\VisualStudio\\SxS\\VS7", "15.0", "MSBuild\\15.0\\bin\\csc.exe", out toolPath)) { return(toolPath); } toolPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "MSBuild", "14.0", "bin", "csc.exe"); if (File.Exists(toolPath)) { return(toolPath); } if (CheckMsBuildPathFromRegistry("Microsoft\\MSBuild\\ToolsVersions\\14.0", "MSBuildToolsPath", "csc.exe", out toolPath)) { return(toolPath); } if (CheckMsBuildPathFromRegistry("Microsoft\\MSBuild\\ToolsVersions\\12.0", "MSBuildToolsPath", "csc.exe", out toolPath)) { return(toolPath); } if (CheckMsBuildPathFromRegistry("Microsoft\\MSBuild\\ToolsVersions\\4.0", "MSBuildToolsPath", "csc.exe", out toolPath)) { return(toolPath); } break; } } return(string.Empty); }
private static string GetMSBuildToolPath() { string toolPath; switch (Platform.BuildPlatform.Target) { case TargetPlatform.Linux: { // Use msbuild from Mono toolPath = UnixPlatform.Which("msbuild"); if (toolPath != null) { return(toolPath); } break; } case TargetPlatform.Windows: { var visualStudioInstances = VisualStudioInstance.GetInstances(); foreach (var visualStudioInstance in visualStudioInstances) { toolPath = Path.Combine(visualStudioInstance.Path, "MSBuild\\Current\\Bin\\MSBuild.exe"); if (File.Exists(toolPath)) { return(toolPath); } } if (CheckMsBuildPathFromRegistry("Microsoft\\VisualStudio\\SxS\\VS7", "15.0", "MSBuild\\15.0\\bin\\MSBuild.exe", out toolPath)) { return(toolPath); } toolPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "MSBuild", "14.0", "bin", "MSBuild.exe"); if (File.Exists(toolPath)) { return(toolPath); } if (CheckMsBuildPathFromRegistry("Microsoft\\MSBuild\\ToolsVersions\\14.0", "MSBuildToolsPath", "MSBuild.exe", out toolPath)) { return(toolPath); } if (CheckMsBuildPathFromRegistry("Microsoft\\MSBuild\\ToolsVersions\\12.0", "MSBuildToolsPath", "MSBuild.exe", out toolPath)) { return(toolPath); } if (CheckMsBuildPathFromRegistry("Microsoft\\MSBuild\\ToolsVersions\\4.0", "MSBuildToolsPath", "MSBuild.exe", out toolPath)) { return(toolPath); } break; } } return(string.Empty); }