/// <summary> /// Gets the Visual Studio version of the current project. /// </summary> /// <returns>The version of the current project.</returns> private VisualStudioVersion GetVsVersion() { VisualStudioVersion vsVer = VisualStudioVersion.Unknown; double product; if (Double.TryParse(this.productVersion.Value, out product)) { if (product == 7) { vsVer = VisualStudioVersion.VisualStudio2002; } else if (product == 7.1) { vsVer = VisualStudioVersion.VisualStudio2003; } else if (product == 8) { vsVer = VisualStudioVersion.VisualStudio2005; } else if (product == 9) { vsVer = VisualStudioVersion.VisualStudio2008; } else if (product == 10) { vsVer = VisualStudioVersion.VisualStudio2010; } } return(vsVer); }
/// <summary> /// Converts to VS2010 version. /// </summary> /// <param name="vsVersion">The Visual Studio version.</param> private void ConvertToVs2010(VisualStudioVersion vsVersion) { if (this.toolsVersion != null) { double tools; if (Double.TryParse(this.toolsVersion.Value, out tools) && tools != 4.0) { this.toolsVersion.Value = "4.0"; } } else { this.project.Root.Add(new XAttribute(XName.Get("ToolsVersion"), "4.0")); } if (this.productVersion != null) { this.productVersion.Value = "10.0.30319.1"; } if (this.targetFrameworkVersion == null) { XElement newToolsVersion = new XElement(XName.Get("TargetFrameworkVersion", this.namespaceName), "v2.0"); this.project.Root.Element(XName.Get("PropertyGroup", this.namespaceName)).Add(newToolsVersion); } if (this.importProject != null && !this.importProject.Value.Contains("$(MSBuildToolsPath)")) { this.importProject.Value = this.importProject.Value.Replace("$(MSBuildBinPath)", "$(MSBuildToolsPath)"); } }
/// <summary> /// Reloads the current project. /// </summary> /// <returns><c>true</c> if successful; <c>false</c> otherwise.</returns> public bool Reload() { try { this.project = XDocument.Load(this.projectPath); } catch (Exception) { this.project = null; } bool ret = false; this.vsVersion = VisualStudioVersion.Unknown; this.IsReady = false; if (this.project != null) { this.toolsVersion = this.project.Root.Attribute(XName.Get("ToolsVersion")); this.productVersion = this.project.Root.Element(XName.Get("PropertyGroup", this.namespaceName)).Element(XName.Get("ProductVersion", this.namespaceName)); this.targetFrameworkVersion = this.project.Root.Element(XName.Get("PropertyGroup", this.namespaceName)).Element(XName.Get("TargetFrameworkVersion", this.namespaceName)); this.importProject = this.project.Root.Element(XName.Get("Import", this.namespaceName)).Attribute(XName.Get("Project")); this.Name = Path.GetFileNameWithoutExtension(this.projectPath); this.vsVersion = this.GetVsVersion(); this.IsReady = true; ret = true; } return(ret); }
public MainViewModel(ILogger logger) { VisualStudioVersions = Enum.GetValues(typeof(VisualStudioVersion)).Cast<VisualStudioVersion>().ToArray(); _selectedVisualStudioVersion = VisualStudioVersion.VisualStudio2015; _logger = logger; _missingProjects = new ObservableCollection<FileInfo>(); }
private static bool TryGetVisualStudioVersion(string externalEditor, out VisualStudioVersion vsVersion) { switch (ProductVersion(externalEditor).Major) { case 9: vsVersion = VisualStudioVersion.VisualStudio2008; return(true); case 10: vsVersion = VisualStudioVersion.VisualStudio2010; return(true); case 11: vsVersion = VisualStudioVersion.VisualStudio2012; return(true); case 12: vsVersion = VisualStudioVersion.VisualStudio2013; return(true); case 14: vsVersion = VisualStudioVersion.VisualStudio2015; return(true); case 15: vsVersion = VisualStudioVersion.VisualStudio2017; return(true); } vsVersion = VisualStudioVersion.Invalid; return(false); }
/// <inheritdoc /> public IVisualStudio LaunchVisualStudio(VisualStudioVersion version, ILogger logger) { if (logger == null) { throw new ArgumentNullException("logger"); } Pair <string, VisualStudioVersion>?installDirAndVersion = GetVisualStudioInstallDirAndVersion(version); if (!installDirAndVersion.HasValue) { logger.Log(LogSeverity.Debug, string.Format("Could not find Visual Studio version '{0}'.", version)); return(null); } string devenvPath = Path.Combine(installDirAndVersion.Value.First, "devenv.exe"); ProcessTask devenvProcessTask = new ProcessTask(devenvPath, "", Environment.CurrentDirectory); logger.Log(LogSeverity.Debug, string.Format("Launching Visual Studio using path: '{0}'.", devenvProcessTask.ExecutablePath)); devenvProcessTask.Start(); System.Diagnostics.Process devenvProcess = devenvProcessTask.Process; if (devenvProcess != null) { int processId = devenvProcess.Id; Stopwatch stopwatch = Stopwatch.StartNew(); for (;;) { IVisualStudio visualStudio = GetVisualStudioFromProcess(processId, installDirAndVersion.Value.Second, true, logger); if (visualStudio != null) { return(visualStudio); } if (stopwatch.ElapsedMilliseconds > VisualStudioAttachTimeoutMilliseconds) { logger.Log(LogSeverity.Debug, string.Format("Stopped waiting for Visual Studio to launch after {0} milliseconds.", VisualStudioAttachTimeoutMilliseconds)); break; } if (!devenvProcessTask.IsRunning) { break; } Thread.Sleep(500); } } if (devenvProcessTask.IsTerminated && devenvProcessTask.Result != null) { if (!devenvProcessTask.Result.HasValue) { logger.Log(LogSeverity.Debug, "Failed to launch Visual Studio.", devenvProcessTask.Result.Exception); } } return(null); }
internal WinRTSolutionWriter(AssemblyDefinition assembly, TargetPlatform targetPlatform, string targetDir, string solutionFileName, Dictionary <ModuleDefinition, string> modulesProjectsRelativePaths, Dictionary <ModuleDefinition, Guid> modulesProjectsGuids, VisualStudioVersion visualStudioVersion, ILanguage language, IEnumerable <string> platforms) : base(assembly, targetPlatform, targetDir, solutionFileName, modulesProjectsRelativePaths, modulesProjectsGuids, visualStudioVersion, language) { this.platforms = platforms; }
static void FindVisualStudio(string externalEditor, out VisualStudioVersion vsVersion, Dictionary <VisualStudioVersion, string[]> installedVisualStudios) { if (string.IsNullOrEmpty(externalEditor)) { vsVersion = VisualStudioVersion.Invalid; return; } // If it's a VS found through envvars or the registry var matches = installedVisualStudios.Where(kvp => kvp.Value.Any(v => Path.GetFullPath(v).Equals(Path.GetFullPath(externalEditor), StringComparison.OrdinalIgnoreCase))).ToArray(); if (matches.Length > 0) { vsVersion = matches[0].Key; return; } // If it's a side-by-side VS selected manually if (externalEditor.EndsWith("devenv.exe", StringComparison.OrdinalIgnoreCase)) { if (TryGetVisualStudioVersion(externalEditor, out vsVersion)) { return; } } vsVersion = VisualStudioVersion.Invalid; }
internal SolutionWriter(AssemblyDefinition assembly, TargetPlatform targetPlatform, string targetDir, string solutionFileName, Dictionary<ModuleDefinition, string> modulesProjectsRelativePaths, Dictionary<ModuleDefinition, Guid> modulesProjectsGuids, VisualStudioVersion visualStudioVersion, ILanguage language) { this.assembly = assembly; this.targetPlatform = targetPlatform; this.targetDir = targetDir; this.solutionFileName = solutionFileName; this.modulesProjectsRelativePaths = modulesProjectsRelativePaths; this.modulesProjectsGuids = modulesProjectsGuids; if (language is ICSharp) { this.languageGuid = new Guid(WinRTProjectBuilder.CSharpGUID); } else if (language is IVisualBasic) { this.languageGuid = new Guid(WinRTProjectBuilder.VisualBasicGUID); } else { throw new NotSupportedException(); } this.visualStudioVersion = visualStudioVersion; }
public override Task <CreateProjectResponse> CreateProject(CreateProjectRequest request, ServerCallContext context) { if (string.IsNullOrEmpty(request.OutputPath) || string.IsNullOrEmpty(request.AssemblyFilePath)) { throw new RpcException(new Status(StatusCode.InvalidArgument, "Invalid argument")); } bool decompileDangerousResources = request.DecompileDangerousResources; VisualStudioVersion visualStudioVersion = this.GetProjectCreationVSVersion(request.ProjectVisualStudioVersion); ILanguage language = LanguageFactory.GetLanguage(CSharpVersion.V7); AssemblyDefinition assembly = GlobalAssemblyResolver.Instance.GetAssemblyDefinition(request.AssemblyFilePath); ProjectGenerationSettings settings = ProjectGenerationSettingsProvider.GetProjectGenerationSettings(request.AssemblyFilePath, NoCacheAssemblyInfoService.Instance, EmptyResolver.Instance, visualStudioVersion, language, TargetPlatformResolver.Instance); DecompilationPreferences preferences = new DecompilationPreferences() { WriteFullNames = false, WriteDocumentation = true, RenameInvalidMembers = true, WriteLargeNumbersInHex = false, DecompileDangerousResources = decompileDangerousResources }; BaseProjectBuilder projectBuilder = this.GetProjectBuilder(assembly, request.AssemblyFilePath, visualStudioVersion, settings, language, request.OutputPath, preferences, EmptyResolver.Instance, TargetPlatformResolver.Instance); string generationErrorMessage = this.CreateProject(projectBuilder); return(Task.FromResult(new CreateProjectResponse() { ErrorMessage = generationErrorMessage })); }
private static string GetVstuBridgeAssembly(VisualStudioVersion version) { string result; try { string vsTargetYear = string.Empty; switch (version) { case VisualStudioVersion.VisualStudio2010: vsTargetYear = "2010"; break; case VisualStudioVersion.VisualStudio2012: vsTargetYear = "2012"; break; case VisualStudioVersion.VisualStudio2013: vsTargetYear = "2013"; break; case VisualStudioVersion.VisualStudio2015: vsTargetYear = "2015"; break; } result = (UnityVSSupport.GetVstuBridgePathFromRegistry(vsTargetYear, true) ?? UnityVSSupport.GetVstuBridgePathFromRegistry(vsTargetYear, false)); } catch (Exception) { result = null; } return(result); }
internal SolutionWriter(AssemblyDefinition assembly, TargetPlatform targetPlatform, string targetDir, string solutionFileName, Dictionary <ModuleDefinition, string> modulesProjectsRelativePaths, Dictionary <ModuleDefinition, Guid> modulesProjectsGuids, VisualStudioVersion visualStudioVersion, ILanguage language) { this.assembly = assembly; this.targetPlatform = targetPlatform; this.targetDir = targetDir; this.solutionFileName = solutionFileName; this.modulesProjectsRelativePaths = modulesProjectsRelativePaths; this.modulesProjectsGuids = modulesProjectsGuids; if (language is Telerik.JustDecompiler.Languages.CSharp.CSharp) { this.languageGuid = new Guid(WinRTProjectBuilder.CSharpGUID); } else if (language is Telerik.JustDecompiler.Languages.VisualBasic.VisualBasic) { this.languageGuid = new Guid(WinRTProjectBuilder.VisualBasicGUID); } else { throw new NotSupportedException(); } this.visualStudioVersion = visualStudioVersion; }
public static VisualStudioVersion GetVsVersion(string version) { VisualStudioVersion vsVer = VisualStudioVersion.Unknown; double product; if (Double.TryParse(version, out product)) { if (product == 7) { vsVer = VisualStudioVersion.VisualStudio2002; } else if (product == 7.1) { vsVer = VisualStudioVersion.VisualStudio2003; } else if (product == 8) { vsVer = VisualStudioVersion.VisualStudio2005; } else if (product == 9) { vsVer = VisualStudioVersion.VisualStudio2008; } else if (product == 10) { vsVer = VisualStudioVersion.VisualStudio2010; } } return(vsVer); }
/// <summary> /// 指定的版本的Bootstrapper,如:1.0、3.5、4.0等 /// </summary> /// <param name="version"></param> /// <returns></returns> public static string GetBootstrappersPath(VisualStudioVersion version) { string strVer; switch (version) { case VisualStudioVersion.VisualStudio2002: strVer = "1.0"; break; case VisualStudioVersion.VisualStudio2003: strVer = "1.1"; break; case VisualStudioVersion.VisualStudio2005: strVer = "2.0"; break; case VisualStudioVersion.VisualStudio2008: strVer = "3.5"; break; case VisualStudioVersion.VisualStudio2010: strVer = "4.0"; break; default: strVer = "3.5"; break; } string result = null; RegistryKey keyBootstrapper; keyBootstrapper = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\GenericBootstrapper\" + strVer); if (keyBootstrapper == null) { keyBootstrapper = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\GenericBootstrapper\" + strVer); } if (keyBootstrapper != null) { result = keyBootstrapper.GetValue("Path") as string; } return(result); }
public TestWinRTProjectBuilder(string assemblyPath, AssemblyDefinition assembly, Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<TypeDefinition>> userDefinedTypes, Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<Resource>> resources, string targetPath, ILanguage language, IDecompilationPreferences preferences, VisualStudioVersion visualStudioVersion, ProjectGenerationSettings projectGenerationSettings = null) : base(assemblyPath, assembly, userDefinedTypes, resources, targetPath, language, preferences, NoCacheAssemblyInfoService.Instance, visualStudioVersion, projectGenerationSettings) { }
public static string GetVisualStudioExecutable(VisualStudioVersion visualStudioVersion) { string installPath; switch (visualStudioVersion) { case VisualStudioVersion.VS2010: case VisualStudioVersion.VS2012: case VisualStudioVersion.VS2013: case VisualStudioVersion.VS2015: { using (var hiveKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) { var regPath = string.Format(@"Software\Microsoft\VisualStudio\{0}", GetVersionKey(visualStudioVersion)); using (var key = hiveKey.OpenSubKey(regPath)) { installPath = key.GetValue("InstallDir") as string; } break; } } default: { var setupInstances = new ISetupInstance[10]; new SetupConfiguration().EnumAllInstances().Next(setupInstances.Length, setupInstances, out var fetched); var installedVSInstances = setupInstances.Take(fetched).Select((l, idx) => new { MajorVersion = setupInstances[idx].GetInstallationVersion().Split('.').First(), Path = setupInstances[idx].GetInstallationPath(), InstallDay = setupInstances[idx].GetInstallDate().dwHighDateTime, }).OrderByDescending(l => l.InstallDay).ToArray(); //Why: parallel early installed (Preview, RC) Versions installPath = installedVSInstances.First(l => GetVersionKey(visualStudioVersion).StartsWith(l.MajorVersion)).Path; installPath = Path.Combine(installPath, "Common7", "IDE"); break; } } return(Path.Combine(installPath, "devenv.exe")); }
private static string GetVersionKey(VisualStudioVersion visualStudioVersion) { if (visualStudioVersion == VisualStudioVersion.VS2012) { return "11.0"; } return "10.0"; }
private static List <string> GetSystemIncludes(VisualStudioVersion vsVersion, string vsDir) { if (vsVersion == VisualStudioVersion.VS2017) { return(GetSystemIncludesVS2017(vsDir)); } int windowsSdkMajorVer; var windowsKitSdk = GetWindowsKitsToolchain(vsVersion, out windowsSdkMajorVer); List <ToolchainVersion> windowsSdks; GetWindowsSdks(out windowsSdks); var includes = new List <string> { Path.Combine(vsDir, @"VC\include") }; // Older Visual Studio versions provide their own Windows SDK. if (windowsSdks.Count == 0) { includes.Add(Path.Combine(vsDir, @"\VC\PlatformSDK\Include")); } else { includes.AddRange(GetIncludeDirsFromWindowsSdks(windowsSdkMajorVer, windowsSdks)); } includes.AddRange( CollectUniversalCRuntimeIncludeDirs(vsDir, windowsKitSdk, windowsSdkMajorVer)); return(includes); }
static bool IsVisualStudio(string externalEditor, out VisualStudioVersion vsVersion) { if (string.IsNullOrEmpty(externalEditor)) { vsVersion = VisualStudioVersion.Invalid; return(false); } // If it's a VS found through envvars or the registry var matches = SyncVS.InstalledVisualStudios.Where(kvp => kvp.Value.Any(v => UnityEditor.Utils.Paths.AreEqual(v.Path, externalEditor, true))).ToArray(); if (matches.Length > 0) { vsVersion = matches[0].Key; return(true); } // If it's a side-by-side VS selected manually if (externalEditor.EndsWith("devenv.exe", StringComparison.OrdinalIgnoreCase)) { if (TryGetVisualStudioVersion(externalEditor, out vsVersion)) { return(true); } } vsVersion = VisualStudioVersion.Invalid; return(false); }
public static string GetDefaultProjectsLocation(VisualStudioVersion visualStudioVersion) { RegistryKey key = null; string location = null; try { key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\" + GetVersionKey(visualStudioVersion)); if (key != null) { location = key.GetValue("DefaultNewProjectLocation") as string; } if (String.IsNullOrEmpty(location)) { location = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Visual Studio 2010", "Projects"); } return(location); } finally { if (key != null) { key.Close(); } } }
/// <summary> /// Initializes a new instance of the MockSolution class. /// </summary> public MockSolution(FileInfo solutionFile, IList<ISolutionProjectInfo> projectListe, string rawContent, VisualStudioVersion version) { SolutionFile = solutionFile; ProjectListe = projectListe; RawContent = rawContent; Version = version; }
public void SetupMSVC() { VisualStudioVersion vsVersion = VisualStudioVersion.Latest; // Silence "warning CS0162: Unreachable code detected" #pragma warning disable 162 switch (BuildConfig.Choice) { case "vs2012": vsVersion = VisualStudioVersion.VS2012; break; case "vs2013": vsVersion = VisualStudioVersion.VS2013; break; case "vs2015": vsVersion = VisualStudioVersion.VS2015; break; case "vs2017": vsVersion = VisualStudioVersion.VS2017; break; #pragma warning restore 162 } SetupMSVC(vsVersion); }
private static string GetRegistryKeyName(VisualStudioVersion version) { string subKey; switch (version) { case VisualStudioVersion.Vs2010: subKey = "VANet10"; break; case VisualStudioVersion.Vs2012: case VisualStudioVersion.Vs2013: case VisualStudioVersion.Vs2015: subKey = "VANet11"; break; case VisualStudioVersion.Unknown: default: // Default to the Vs2010 version subKey = "VANet10"; break; } return(RegistryBaseKeyName + subKey); }
internal WinRTSolutionWriter(AssemblyDefinition assembly, TargetPlatform targetPlatform, string targetDir, string solutionFileName, Dictionary<ModuleDefinition, string> modulesProjectsRelativePaths, Dictionary<ModuleDefinition, Guid> modulesProjectsGuids, VisualStudioVersion visualStudioVersion, ILanguage language, IEnumerable<string> platforms) : base(assembly, targetPlatform, targetDir, solutionFileName, modulesProjectsRelativePaths, modulesProjectsGuids, visualStudioVersion, language) { this.platforms = platforms; }
/// Gets the system include folders for the given Visual Studio version. public static List <string> GetSystemIncludes(VisualStudioVersion vsVersion) { var vsSdk = GetVSToolchain(vsVersion); var vsDir = vsSdk.Directory; vsDir = vsDir.Substring(0, vsDir.LastIndexOf(@"\Common7\IDE", StringComparison.Ordinal)); if (vsVersion != VisualStudioVersion.Latest) { return(GetSystemIncludes(vsVersion, vsDir)); } // we don't know what "latest" is on a given machine // because we do not (yet) pass a parameter from the build scripts // so start from the latest specified version and loop until a match is found for (var i = VisualStudioVersion.Latest - 1; i >= VisualStudioVersion.VS2012; i--) { var includes = GetSystemIncludes(i, vsDir); if (includes.Any()) { return(includes); } } return(new List <string>()); }
public static bool OpenFile(VisualStudioVersion version, string fileName) { if (!IsInstalled(version)) { return(false); } if (string.IsNullOrWhiteSpace(fileName)) { return(false); } var path = GetInstallationFolder(version); if (string.IsNullOrWhiteSpace(path)) { return(false); } try { var cmd = Path.Combine(path, Exe); Process.Start(cmd, $"/Edit \"{fileName}\""); return(true); } catch (Exception) { return(false); } }
public SaveSolutionCommand(ISettings settings, string solutionFileName, VisualStudioVersion visualStudioVersion, SolutionViewModel solution) { _settings = settings; _solutionFileName = solutionFileName; _visualStudioVersion = visualStudioVersion; _solution = solution; }
private static string GetVstuBridgeAssembly(VisualStudioVersion version) { try { string vsTargetYear = string.Empty; switch (version) { case VisualStudioVersion.VisualStudio2010: vsTargetYear = "2010"; break; case VisualStudioVersion.VisualStudio2012: vsTargetYear = "2012"; break; case VisualStudioVersion.VisualStudio2013: vsTargetYear = "2013"; break; case VisualStudioVersion.VisualStudio2015: vsTargetYear = "2015"; break; } return UnityVSSupport.GetVstuBridgePathFromRegistry(vsTargetYear, true) ?? UnityVSSupport.GetVstuBridgePathFromRegistry(vsTargetYear, false); } catch (Exception ex) { return (string) null; } }
/// <summary> /// Copies settings from a Visual Studio installation to Sql Server Management Studio. /// </summary> /// <param name="vsVersion">Represents the version of Visual Studio from which we will read the settings.</param> /// <param name="sqlVersion">Represents the version of SSMS which will receive the settings.</param> public void CopyVSToSql(VisualStudioVersion vsVersion, SqlStudioVersion sqlVersion) { string vsRegKeyPath = string.Format(_vsRegKeyFormat, _versionStrings[Enum.GetName(typeof(VisualStudioVersion), vsVersion)]); string sqlRegKeyPath = string.Format(_sqlRegKeyFormat, _versionStrings[Enum.GetName(typeof(SqlStudioVersion), sqlVersion)]); CreateMappingsFromVisualStudioToSql(); Copy(vsRegKeyPath, sqlRegKeyPath); }
internal SolutionWriter(AssemblyDefinition assembly, string targetDir, string solutionFileName, Dictionary <ModuleDefinition, string> modulesProjectsRelativePaths, Dictionary <ModuleDefinition, Guid> modulesProjectsGuids, VisualStudioVersion visualStudioVersion, ILanguage language) { this.assembly = assembly; this.targetDir = targetDir; this.solutionFileName = solutionFileName; this.modulesProjectsRelativePaths = modulesProjectsRelativePaths; this.modulesProjectsGuids = modulesProjectsGuids; if (language is ICSharp) { this.languageGuid = new Guid(LanguageConstants.CSharpGUID); } else if (language is IVisualBasic) { this.languageGuid = new Guid(LanguageConstants.VisualBasicGUID); } else { throw new NotSupportedException(); } this.visualStudioVersion = visualStudioVersion; }
private static string GetDevEvnBaseRegistryKey(VisualStudioVersion version) { //TODO: This hack gets us the right registry path for 32-bit software on 64 bit Windows. // The right fix is to either build an x86 target (rather than "Any CPU"), or to build // against .NET Framework 4 (or greater) and use RegistryKey.OpenBaseKey to specify that // we want a 32-bit view on the registry. bool is64Bit = IntPtr.Size == 8; string registrySoftwarePath = string.Format(@"SOFTWARE\{0}", is64Bit ? @"Wow6432Node" : ""); switch (version) { case VisualStudioVersion.VS2005: return(registrySoftwarePath + @"\Microsoft\VisualStudio\8.0\Setup\VS"); case VisualStudioVersion.VS2008: return(registrySoftwarePath + @"\Microsoft\VisualStudio\9.0\Setup\VS"); case VisualStudioVersion.VS2010: return(registrySoftwarePath + @"\Microsoft\VisualStudio\10.0\Setup\VS"); case VisualStudioVersion.VS2012: return(registrySoftwarePath + @"\Microsoft\VisualStudio\11.0\Setup\VS"); case VisualStudioVersion.VS2013: return(registrySoftwarePath + @"\Microsoft\VisualStudio\12.0\Setup\VS"); case VisualStudioVersion.VS2015: return(registrySoftwarePath + @"\Microsoft\VisualStudio\14.0\Setup\VS"); case VisualStudioVersion.VS2017: return(registrySoftwarePath + @"\Microsoft\VisualStudio\SxS\VS7"); default: throw new ArgumentException("Couldn't determine Visual Studio registry key. Your version of Visual Studio is unsupported by this tool."); } }
private static bool IsVisualStudio(string externalEditor, out VisualStudioVersion vsVersion) { bool result; if (string.IsNullOrEmpty(externalEditor)) { vsVersion = VisualStudioVersion.Invalid; result = false; } else { KeyValuePair <VisualStudioVersion, string>[] array = (from kvp in SyncVS.InstalledVisualStudios where Paths.AreEqual(kvp.Value, externalEditor, true) select kvp).ToArray <KeyValuePair <VisualStudioVersion, string> >(); if (array.Length > 0) { vsVersion = array[0].Key; result = true; } else { if (externalEditor.EndsWith("devenv.exe", StringComparison.OrdinalIgnoreCase)) { if (UnityVSSupport.TryGetVisualStudioVersion(externalEditor, out vsVersion)) { result = true; return(result); } } vsVersion = VisualStudioVersion.Invalid; result = false; } } return(result); }
/// Gets the system include folders for the given Visual Studio version. public static List <string> GetSystemIncludes(VisualStudioVersion vsVersion) { var vsSdk = GetVSToolchain(vsVersion); int windowsSdkMajorVer; var windowsKitSdk = GetWindowsKitsToolchain(vsVersion, out windowsSdkMajorVer); var vsDir = vsSdk.Directory; vsDir = vsDir.Substring(0, vsDir.LastIndexOf(@"\Common7\IDE", StringComparison.Ordinal)); var includes = new List <string>(); includes.Add(Path.Combine(vsDir, @"VC\include")); List <ToolchainVersion> windowsSdks; GetWindowsSdks(out windowsSdks); // Older Visual Studio versions provide their own Windows SDK. if (windowsSdks.Count == 0) { includes.Add(Path.Combine(vsDir, @"\VC\PlatformSDK\Include")); } else { includes.AddRange(GetIncludeDirsFromWindowsSdks(windowsSdkMajorVer, windowsSdks)); } includes.AddRange( CollectUniversalCRuntimeIncludeDirs(vsDir, windowsKitSdk, windowsSdkMajorVer)); return(includes); }
public static int GetCLVersion(VisualStudioVersion vsVersion) { int clVersion; switch (vsVersion) { case VisualStudioVersion.VS2012: clVersion = 17; break; case VisualStudioVersion.VS2013: clVersion = 18; break; case VisualStudioVersion.VS2015: case VisualStudioVersion.Latest: clVersion = 19; break; default: throw new Exception("Unknown Visual Studio version"); } return(clVersion); }
private static bool TryGetVisualStudioVersionParam(string[] args, out VisualStudioVersion visualStudioVersion, ref bool isInvalidVisualStudioVersion) { string visualStudioVersionAsString; bool visualStudioVersionParamPresented = TryGetParam(args, "/vs", out visualStudioVersionAsString); if (visualStudioVersionParamPresented) { switch (visualStudioVersionAsString) { case "2010": visualStudioVersion = VisualStudioVersion.VS2010; return(true); case "2012": visualStudioVersion = VisualStudioVersion.VS2012; return(true); case "2013": visualStudioVersion = VisualStudioVersion.VS2013; return(true); default: isInvalidVisualStudioVersion = true; break; } } visualStudioVersion = VisualStudioVersion.Unknown; return(false); }
/// <summary> /// Sets up the parser options to work with the given Visual Studio toolchain. /// </summary> /// <param name="vsVersion">The version of Visual Studio to look for.</param> public void SetupMSVC(VisualStudioVersion vsVersion) { MicrosoftMode = true; Abi = CppAbi.Microsoft; var clVersion = MSVCToolchain.GetCLVersion(vsVersion); ToolSetToUse = clVersion.Major * 10000000 + clVersion.Minor * 100000; if (!ForceClangToolchainLookup) { NoStandardIncludes = true; NoBuiltinIncludes = true; vsVersion = MSVCToolchain.FindVSVersion(vsVersion); foreach (var include in MSVCToolchain.GetSystemIncludes(vsVersion)) { AddSystemIncludeDirs(include); } } // do not remove the CppSharp prefix becase the Mono C# compiler breaks if (!LanguageVersion.HasValue) { LanguageVersion = CppSharp.Parser.LanguageVersion.CPP14_GNU; } AddArguments("-fms-extensions"); AddArguments("-fms-compatibility"); AddArguments("-fdelayed-template-parsing"); }
private ViewSourceControlHistoryCommand(Package package) { _package = package; #if DEBUG MessageHelper.ShowMessage("UserRegistryRoot=" + _package.UserRegistryRoot); #endif // Detect Visual Studio version { var vsRegistryRoot = _package.UserRegistryRoot.ToString(); // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (vsRegistryRoot.Contains(@"\12")) { _vsVersion = VisualStudioVersion.VS2013; } else if (vsRegistryRoot.Contains(@"\14")) { _vsVersion = VisualStudioVersion.VS2015; } else if (vsRegistryRoot.Contains(@"\15")) { _vsVersion = VisualStudioVersion.VS2017; } else if (vsRegistryRoot.Contains(@"\16")) { _vsVersion = VisualStudioVersion.VS2019; } else { throw new ApplicationException($"Unknown version of VisualStudioVersion: {vsRegistryRoot}"); } } // Add our command handlers for menu (commands must exist in the .vsct file) if (ServiceProvider.GetService(typeof(IMenuCommandService)) is OleMenuCommandService menuCommandService) { // Create the command for the menu item. var menuCommandID = new CommandID(GuidList.GuidTfsVisualHistoryVSExtensionCmdSet, (int)PkgCmdIDList.CmdSitronicsVisualizeHistory); var menuItem = new MenuCommand(MenuItemCallback, menuCommandID); /* * menuItem.BeforeQueryStatus += (sender, evt) => * { * // I don't need this next line since this is a lambda. * // But I just wanted to show that sender is the OleMenuCommand. * var item = (OleMenuCommand)sender; * * // var service = (EnvDTE.DTE)this.GetService(typeof(EnvDTE.DTE)); * item.Enabled = false;//TeamExplorerIntegrator.IsSingleSelected; * }; */ menuCommandService.AddCommand(menuItem); } }
public WinRTProjectBuilder(string assemblyPath, string targetPath, ILanguage language, IDecompilationPreferences preferences, IFileGenerationNotifier notifier, IAssemblyInfoService assemblyInfoService, VisualStudioVersion visualStudioVersion = VisualStudioVersion.VS2010, ProjectGenerationSettings projectGenerationSettings = null) : base(assemblyPath, targetPath, language, null, preferences, notifier, assemblyInfoService, visualStudioVersion, projectGenerationSettings) { Initialize(); }
/// Dumps include directories for selected toolchain. public static void DumpSdkIncludes(VisualStudioVersion vsVersion = VisualStudioVersion.Latest) { Console.WriteLine("\nInclude search path (VS: {0}):", vsVersion); var includes = GetSystemIncludes(vsVersion); foreach (var include in includes) Console.WriteLine("\t{0}", include); }
private static string GetVersionNumber(VisualStudioVersion version) { if (version == VisualStudioVersion.Other) { throw new InvalidOperationException("Version not supported."); } return($"{(int) version/10:f1}"); }
internal static DTE Create(VisualStudioVersion visualStudioVersion) { var vsProgID = visualStudioVersion.ToDescription(); var type = Type.GetTypeFromProgID(vsProgID, true); var obj = Activator.CreateInstance(type, true); return obj as DTE; }
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"); } }
public static string GetVisualStudioExecutable(VisualStudioVersion visualStudioVersion) { var regPath = String.Format(@"Software\{0}Microsoft\VisualStudio\{1}", Environment.Is64BitOperatingSystem ? @"Wow6432Node\" : String.Empty, GetVersionKey(visualStudioVersion)); using (var key = Registry.LocalMachine.OpenSubKey(regPath)) { var installPath = key.GetValue("InstallDir") as string; return Path.Combine(installPath, "devenv.exe"); } }
private static string GetVersionKey(VisualStudioVersion visualStudioVersion) { switch (visualStudioVersion) { case VisualStudioVersion.VS2012: return "11.0"; case VisualStudioVersion.VS2013: return "12.0"; } return "10.0"; }
/// <inheritdoc /> public IVisualStudio GetVisualStudio(VisualStudioVersion version, bool launchIfNoActiveInstance, ILogger logger) { if (logger == null) throw new ArgumentNullException("logger"); IVisualStudio visualStudio = GetActiveVisualStudio(version, logger); if (visualStudio == null && launchIfNoActiveInstance) visualStudio = LaunchVisualStudio(version, logger); return visualStudio; }
public SolutionWrapper(string solutionName, VisualStudioVersion visualStudioVersion, ILogger logger) { _solutionName = solutionName; _visualStudioVersion = visualStudioVersion; _logger = logger; _projectWrappers = new List<ProjectWrapper>(); _dte = EnvDTEFactory.Create(visualStudioVersion); _nonUpdatedProjects = new ObservableCollection<ProjectWrapper>(); NonUpdatedProjects = new ReadOnlyCollection<ProjectWrapper>(_nonUpdatedProjects); }
public MainViewModel(ILogger logger) { VisualStudioVersions = Enum.GetValues(typeof(VisualStudioVersion)).Cast<VisualStudioVersion>().ToArray(); TargetFrameworkVersions = Enum.GetValues(typeof(TargetFramework)).Cast<TargetFramework>().ToArray(); _selectedVisualStudioVersion = VisualStudioVersion.VisualStudio2015; _selectedTargetFramework = TargetFramework.v4_5; _logger = logger; _nonUpdatedProjects = new ObservableCollection<ProjectWrapper>(); }
internal static string GetVisualStudioInstallationDir(VisualStudioVersion version) { string registryKeyString = String.Format(@"SOFTWARE{0}Microsoft\VisualStudio\{1}", Environment.Is64BitProcess ? @"\Wow6432Node\" : "\\", GetVersionNumber(version)); using (var localMachineKey = Registry.LocalMachine.OpenSubKey(registryKeyString)) { return localMachineKey.GetValue("InstallDir") as string; } }
/// <summary> /// Creates a wrapper for a particular DTE object. /// </summary> /// <param name="dte">The DTE object to wrap.</param> /// <param name="version">The version of Visual Studio represented by this object.</param> /// <param name="wasLaunched">True if Visual Studio was launched by our code, false if an existing instance was obtained.</param> /// <param name="logger">The logger.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="dte"/> or <paramref name="logger"/> is null.</exception> public VisualStudio(DTE dte, VisualStudioVersion version, bool wasLaunched, ILogger logger) { if (logger == null) throw new ArgumentNullException("logger"); if (dte == null) throw new ArgumentNullException("dte"); this.logger = logger; this.dte = dte; this.version = version; this.wasLaunched = wasLaunched; }
/// <inheritdoc /> public IVisualStudio LaunchVisualStudio(VisualStudioVersion version, ILogger logger) { if (logger == null) throw new ArgumentNullException("logger"); Pair<string, VisualStudioVersion>? installDirAndVersion = GetVisualStudioInstallDirAndVersion(version); if (!installDirAndVersion.HasValue) { logger.Log(LogSeverity.Debug, string.Format("Could not find Visual Studio version '{0}'.", version)); return null; } string devenvPath = Path.Combine(installDirAndVersion.Value.First, "devenv.exe"); ProcessTask devenvProcessTask = new ProcessTask(devenvPath, "", Environment.CurrentDirectory); logger.Log(LogSeverity.Debug, string.Format("Launching Visual Studio using path: '{0}'.", devenvProcessTask.ExecutablePath)); devenvProcessTask.Start(); System.Diagnostics.Process devenvProcess = devenvProcessTask.Process; if (devenvProcess != null) { int processId = devenvProcess.Id; Stopwatch stopwatch = Stopwatch.StartNew(); for (;;) { IVisualStudio visualStudio = GetVisualStudioFromProcess(processId, installDirAndVersion.Value.Second, true, logger); if (visualStudio != null) return visualStudio; if (stopwatch.ElapsedMilliseconds > VisualStudioAttachTimeoutMilliseconds) { logger.Log(LogSeverity.Debug, string.Format("Stopped waiting for Visual Studio to launch after {0} milliseconds.", VisualStudioAttachTimeoutMilliseconds)); break; } if (!devenvProcessTask.IsRunning) break; Thread.Sleep(500); } } if (devenvProcessTask.IsTerminated && devenvProcessTask.Result != null) { if (! devenvProcessTask.Result.HasValue) logger.Log(LogSeverity.Debug, "Failed to launch Visual Studio.", devenvProcessTask.Result.Exception); } return null; }
public void ReStart(VisualStudioVersion version) { Stop(); var programsFolder = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86); var versionSpecificPathPart = GetVersionSpecificPathPart(version); var executablePath = new FileInfo(Path.Combine(programsFolder, versionSpecificPathPart, "Common7", "IDE", "devenv.exe")); if(!executablePath.Exists) { throw new FileNotFoundException($"Didn't find Visual Studio executable at \"{executablePath}\"."); } // The VisualStudio process spawns a new process with a different ID. Process.Start(new ProcessStartInfo(executablePath.FullName, "/RootSuffix Exp /ResetSkipPkgs")); WaitUntillStarted(TimeSpan.FromMinutes(3)); }
public CodeDomCodeGenerator(IResourceParser resourceParser, string className, string defaultNamespace, CodeDomProvider codeDomProvider = null, TypeAttributes? classAccessibility = null, VisualStudioVersion visualStudioVersion = VisualStudioVersion.VS2012) : base(resourceParser, defaultNamespace) { this.className = className; this.classAccessibility = classAccessibility; this.visualStudioVersion = visualStudioVersion; compileUnit = new CodeCompileUnit(); provider = codeDomProvider ?? new CSharpCodeProvider(); codeNamespace = new CodeNamespace(defaultNamespace); }
/// Sets up the parser options to work with the given Visual Studio toolchain. public void SetupMSVC(VisualStudioVersion vsVersion = VisualStudioVersion.Latest) { MicrosoftMode = true; NoBuiltinIncludes = true; NoStandardIncludes = true; Abi = CppAbi.Microsoft; ToolSetToUse = MSVCToolchain.GetCLVersion(vsVersion) * 10000000; AddArguments("-fms-extensions"); AddArguments("-fms-compatibility"); AddArguments("-fdelayed-template-parsing"); var includes = MSVCToolchain.GetSystemIncludes(vsVersion); foreach (var include in includes) AddSystemIncludeDirs(include); }
private static bool CheckRegistryKey(VisualStudioVersion version) { try { var keyName = GetRegistryKeyName(version); using (var key = Registry.CurrentUser.OpenSubKey(keyName)) { var value = (byte[])key.GetValue(RegistryValueName); return value.Length > 0 && value[0] != 0; } } catch { // If the registry entry doesn't exist then it's properly set return true; } }
internal VsAdapter( IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, IIncrementalSearchFactoryService incrementalSearchFactoryService, IPowerToolsUtil powerToolsUtil, SVsServiceProvider vsServiceProvider) { _incrementalSearchFactoryService = incrementalSearchFactoryService; _editorAdaptersFactoryService = editorAdaptersFactoryService; _editorOptionsFactoryService = editorOptionsFactoryService; _serviceProvider = vsServiceProvider; _textManager = _serviceProvider.GetService<SVsTextManager, IVsTextManager>(); _table = new RunningDocumentTable(_serviceProvider); _uiShell = _serviceProvider.GetService<SVsUIShell, IVsUIShell>(); _monitorSelection = _serviceProvider.GetService<SVsShellMonitorSelection, IVsMonitorSelection>(); _powerToolsUtil = powerToolsUtil; _visualStudioVersion = vsServiceProvider.GetVisualStudioVersion(); }
internal VimApplicationSettings(VisualStudioVersion visualStudioVersion, WritableSettingsStore settingsStore, IProtectedOperations protectedOperations) { _settingsStore = settingsStore; _protectedOperations = protectedOperations; // Legacy settings were only supported on Visual Studio 2010 and 2012. For any other version there is no // need to modify the legacy settings switch (visualStudioVersion) { case VisualStudioVersion.Vs2010: case VisualStudioVersion.Vs2012: _legacySettingsSupported = true; break; default: // Intentionally do nothing break; } }
public static ProjectGenerationSettings GetProjectGenerationSettings(string assemblyFilePath, IAssemblyInfoService assemblyInfoService, IFrameworkResolver frameworkResolver, VisualStudioVersion visualStudioVersion, ILanguage language) { AssemblyDefinition assembly = Telerik.JustDecompiler.Decompiler.Utilities.GetAssembly(assemblyFilePath); AssemblyInfo assemblyInfo = assemblyInfoService.GetAssemblyInfo(assembly, frameworkResolver); foreach (KeyValuePair<ModuleDefinition, FrameworkVersion> pair in assemblyInfo.ModulesFrameworkVersions) { if (pair.Value == FrameworkVersion.Unknown) { return new ProjectGenerationSettings(true, ResourceStrings.GenerateOnlySourceFilesDueToUnknownFrameworkVersion, false); } else if (pair.Value == FrameworkVersion.WindowsCE || pair.Value == FrameworkVersion.WindowsPhone || (pair.Value == FrameworkVersion.WinRT && WinRTProjectTypeDetector.GetProjectType(assembly) == WinRTProjectType.Unknown)) { return new ProjectGenerationSettings(true, ResourceStrings.GenerateOnlySourceFilesDueToNotSupportedProjectType, false); } } string resultErrorMessage; if (visualStudioVersion == VisualStudioVersion.VS2010) { if (!CanBe2010ProjectCreated(assemblyInfo, out resultErrorMessage)) { return new ProjectGenerationSettings(false, resultErrorMessage); } } else if (visualStudioVersion == VisualStudioVersion.VS2012) { if (!CanBe2012ProjectCreated(assembly, out resultErrorMessage)) { return new ProjectGenerationSettings(false, resultErrorMessage); } } else if (visualStudioVersion == VisualStudioVersion.VS2013) { if (!CanBe2013ProjectCreated(assembly, language, out resultErrorMessage)) { return new ProjectGenerationSettings(false, resultErrorMessage); } } return new ProjectGenerationSettings(true); }
public static int GetCLVersion(VisualStudioVersion vsVersion) { int clVersion; switch (vsVersion) { case VisualStudioVersion.VS2012: clVersion = 17; break; case VisualStudioVersion.VS2013: clVersion = 18; break; case VisualStudioVersion.VS2015: case VisualStudioVersion.Latest: clVersion = 19; break; default: throw new Exception("Unknown Visual Studio version"); } return clVersion; }
private static string GetRegistryKeyName(VisualStudioVersion version) { string subKey; switch (version) { case VisualStudioVersion.Vs2010: subKey = "VANet10"; break; case VisualStudioVersion.Vs2012: case VisualStudioVersion.Vs2013: case VisualStudioVersion.Vs2015: subKey = "VANet11"; break; case VisualStudioVersion.Unknown: default: // Default to the Vs2010 version subKey = "VANet10"; break; } return RegistryBaseKeyName + subKey; }