public static void CloseVisualStudio() { if (_vsInstance?.Solution.IsOpen == true) { _vsInstance.ExecuteCommand("File.SaveAll"); _vsInstance.Solution.Close(true); } _vsInstance?.Quit(); }
private static void CloseVisualStudioInternal() { CallOnSTAThread(() => { if (m_vsInstance?.Solution.IsOpen == true) { m_vsInstance.ExecuteCommand("File.SaveAll"); m_vsInstance.Solution.Close(true); } m_vsInstance?.Quit(); m_vsInstance = null; }); }
public static void ClassCleanup() { if (solution != null) { solution.Close(); solution = null; } if (dte != null) { dte.Quit(); } WebLinterVsix.WebLinterPackage.Settings = null; WebLinterVsix.WebLinterPackage.Dte = null; MessageFilter.Revoke(); }
protected void Cleanup() { if (solution != null) { solution.Close(); solution = null; } if (dte != null) { dte.Quit(); } WebLinterPackage.Settings = null; WebLinterPackage.Dte = null; MessageFilter.Revoke(); }
public static void ClassCleanup() { if (_dte != null) { _dte.Quit(); _dte = null; } if (_msgFilter != null) { _msgFilter.Dispose(); _msgFilter = null; } }
/// <summary> /// Opens a solution and builds it. /// </summary> private void run() { try { dte = getDTE(VSVersion.VS_2017); } catch (Exception e) { Console.WriteLine("Failed to create DTE, check correct Visual Studio version is installed: "); Console.WriteLine(e); this.errorCode = ErrorCode.VS_NOT_FOUND; return; } try { Version twinCatVerison = getInstalledTwinCATVersion(); Console.WriteLine("Twincat version: " + twinCatVerison.ToString()); if (twinCatVerison < new Version(3, 1)) { Console.WriteLine("Requires version 3.1"); this.errorCode = ErrorCode.TWINCAT_NOT_FOUND; return; } } catch (Exception e) { Console.WriteLine("Twincat version not found: " + e.Message); this.errorCode = ErrorCode.TWINCAT_NOT_FOUND; return; } Console.WriteLine("Registering message filter"); int err = MessageFilter.Register(); if (err != 0) { Console.WriteLine("Filter register failed: " + err); this.errorCode = ErrorCode.REGISTER_FAILED; } Solution solution = dte.Solution; Console.WriteLine("Opening " + slnPath); solution.Open(slnPath); Builder builder = new Builder(solution, dte); Project plcProject = builder.findPLCProject(); if (plcProject == null) { Console.WriteLine("No PLC Projects found"); this.errorCode = ErrorCode.PLC_NOT_FOUND; return; } if (this.options.Contains("build")) { if (!builder.buildSolution()) { this.errorCode = ErrorCode.BUILD_FAILED; return; } else { Console.WriteLine("Build Succeeded"); } } Runner runner = new Runner(plcProject, dte); if (this.options.Contains("activate")) { runner.activatePLC(); } if (this.options.Contains("run")) { runner.startPLC(); } if (this.options.Contains("stop")) { runner.stopPLC(); dte.Quit(); } }