/// <inheritdoc/> protected override void Dispose(bool disposing) { foreach (string file in this.TempFilesCreated) { try { File.Delete(file); } catch (Exception ex) { this.LogMessageWriteLineFormat( "There was an error deleting a temp file [{0}], error: [{1}]", file, ex.Message); } } if (this.solutionUpdateCookie > 0) { IVsSolutionBuildManager solutionBuildManager = this.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager; solutionBuildManager.UnadviseUpdateSolutionEvents(this.solutionUpdateCookie); } base.Dispose(disposing); }
public void Dispose() { _solutionBuildManager?.UnadviseUpdateSolutionEvents(_updateCookie); _activeSolutionCancellationTokenSource?.Cancel(); _activeSolutionCancellationTokenSource?.Dispose(); _activeSolutionCancellationTokenSource = null; }
public void Dispose() { // Unregister from receiving solution events if (VSConstants.VSCOOKIE_NIL != _vsSolutionEventsCookie) { IVsSolution sol = (IVsSolution)_sccProvider.GetService(typeof(SVsSolution)); sol.UnadviseSolutionEvents(_vsSolutionEventsCookie); _vsSolutionEventsCookie = VSConstants.VSCOOKIE_NIL; } // Unregister from receiving project documents if (VSConstants.VSCOOKIE_NIL != _tpdTrackProjectDocumentsCookie) { IVsTrackProjectDocuments2 tpdService = (IVsTrackProjectDocuments2)_sccProvider.GetService(typeof(SVsTrackProjectDocuments)); tpdService.UnadviseTrackProjectDocumentsEvents(_tpdTrackProjectDocumentsCookie); _tpdTrackProjectDocumentsCookie = VSConstants.VSCOOKIE_NIL; } // Unregister from storrage events _sccStatusTracker.HGStatusChanged -= new HGLib.HGStatusChangedEvent(SetNodesGlyphsDirty); IVsSolutionBuildManager buildManagerService = _sccProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager; buildManagerService.UnadviseUpdateSolutionEvents(_dwBuildManagerCooky); }
/// <summary> /// Builds the specified project. /// </summary> public async Task <bool> BuildProjectAsync(SolutionItem project, BuildAction action = BuildAction.Build) { if (project?.Type != SolutionItemType.Project && project?.Type != SolutionItemType.VirtualProject) { return(false); } await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); IVsSolutionBuildManager svc = await VS.Services.GetSolutionBuildManagerAsync(); uint buildFlags = (uint)GetBuildFlags(action); project.GetItemInfo(out IVsHierarchy hierarchy, out _, out _); BuildObserver observer = new(hierarchy); ErrorHandler.ThrowOnFailure(svc.AdviseUpdateSolutionEvents(observer, out uint cookie)); try { ErrorHandler.ThrowOnFailure(svc.StartSimpleUpdateProjectConfiguration(hierarchy, null, null, buildFlags, 0, 0)); return(await observer.Result); } finally { svc.UnadviseUpdateSolutionEvents(cookie); } }
protected override void Dispose(bool disposing) { if (disposing) { tools.Release(); tools = null; sharedTaskManagers.Clear(); sharedTaskManagers = null; if (buildManager != null) { buildManager.UnadviseUpdateSolutionEvents(buildManagerCookie); buildManager = null; } if (solution != null) { solution.UnadviseSolutionEvents(solutionEventsCookie); solution = null; } taskListMenu.Release(); taskListMenu = null; Common.Release(); GC.SuppressFinalize(this); } base.Dispose(disposing); }
private static async Task UnadviseSolutionEventsAsync() { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (_updateSolutionEventsCookie != 0) { _solutionBuildManager?.UnadviseUpdateSolutionEvents(_updateSolutionEventsCookie); _updateSolutionEventsCookie = 0; } }
/// [connect with VS] /// [disconnect from VS] /// Release all connections to Visual Studio. /// This function is called from Dispose method of main app class TestExecWindow public void DisconnectFromVisualStudio() { if (m_monitorSelection != null && m_selectionEventsCookie != 0) { m_monitorSelection.UnadviseSelectionEvents(m_selectionEventsCookie); } if (m_solutionBuildManager != null && m_updateSolutionEventsCookie != 0) { m_solutionBuildManager.UnadviseUpdateSolutionEvents(m_updateSolutionEventsCookie); } }
public int UpdateSolution_Done(int succeeded, int modified, int cancelCommand) { if (cancelCommand != 0) { _taskSource.SetCanceled(); } else if (succeeded != 0) { _taskSource.SetResult(true); } else { _taskSource.SetCanceled(); } Marshal.ThrowExceptionForHR(_buildManager.UnadviseUpdateSolutionEvents(_cookie)); return(VSConstants.S_OK); }
/// <summary> /// Called when entire solution is done building /// </summary> /// <param name="fSucceeded">true if no update actions failed</param> /// <param name="fModified">true if any update actions succeeded</param> /// <param name="fCancelCommand">true if update actions were canceled</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns> public int UpdateSolution_Done(int fSucceeded, int fModified, int fCancelCommand) { const int True = 1; _buildManager.UnadviseUpdateSolutionEvents(UpdateSolutionEventsCookie); if (fCancelCommand == True) { _completionSource.SetResult(false); } else if (fSucceeded == True) { _completionSource.SetResult(true); } else { _completionSource.SetResult(false); } return(S_OK); }
/// <summary> /// Builds the solution. /// </summary> public async Task <bool> BuildSolutionAsync(BuildAction action = BuildAction.Build) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); IVsSolutionBuildManager svc = await VS.Services.GetSolutionBuildManagerAsync(); uint buildFlags = (uint)GetBuildFlags(action); BuildObserver observer = new(null); ErrorHandler.ThrowOnFailure(svc.AdviseUpdateSolutionEvents(observer, out uint cookie)); try { ErrorHandler.ThrowOnFailure(svc.StartSimpleUpdateSolutionConfiguration(buildFlags, 0, 0)); return(await observer.Result); } finally { svc.UnadviseUpdateSolutionEvents(cookie); } }
public void Dispose() { monitorSelection.UnadviseSelectionEvents(selectionEventsCookie); solutionBuildManager.UnadviseUpdateSolutionEvents(updateSolutionEventsCookie); }
/// <summary> /// Modifies the property to the original value and unregisters this object from the IVsSolutionBuildManager. /// </summary> private void restoreConfiguration() { ProjectConfiguration.Instance.SetProperty(propertyKey, oldValue); buildManager.UnadviseUpdateSolutionEvents(cookie); }