예제 #1
0
        public void CancelBuild()
        {
            if (BuildAction == BuildActions.BuildActionClean)
            {
                return;
            }
            if (CurrentBuildState != BuildState.InProgress || _buildCancelled || _buildCancelledInternally)
            {
                return;
            }

            try
            {
                // We need to create a separate task here because of some weird things that are going on
                // when calling ExecuteCommand directly. Directly calling it leads to a freeze. No need
                // for that!
                var cancelBuildTask = Task.Run(() => _packageContext.GetDTE().ExecuteCommand(CancelBuildCommand));
                cancelBuildTask.Wait(10000);
                _buildCancelledInternally = true;
            }
            catch (Exception ex)
            {
                ex.Trace("Cancel build failed.");
            }
        }
        public ToolWindowManager(IPackageContext packageContext)
        {
            _dte = packageContext.GetDTE();
            if (_dte == null)
                throw new InvalidOperationException("Unable to get DTE instance.");

            _windowFrame = (IVsWindowFrame)packageContext.GetToolWindow().Frame;
            if (_windowFrame == null)
                throw new InvalidOperationException("Unable to get IVsWindowFrame instance.");

            _window = GetWindowInstance(packageContext.GetDTE(), typeof(ToolWindow).GUID);
            if (_window == null)
                throw new InvalidOperationException("Unable to get Window instance.");
        }
예제 #3
0
        public Tool(IPackageContext packageContext, IBuildInfo buildContext, IBuildDistributor buildDistributor, ControlViewModel viewModel)
        {
            _packageContext = packageContext;
            _dte            = packageContext.GetDTE();
            _dte2           = packageContext.GetDTE2();
            if (_dte == null)
            {
                throw new InvalidOperationException("Unable to get DTE instance.");
            }

            _dteStatusBar = packageContext.GetStatusBar();
            if (_dteStatusBar == null)
            {
                TraceManager.TraceError("Unable to get IVsStatusbar instance.");
            }

            _toolWindowManager = new ToolWindowManager(packageContext);

            _buildContext     = buildContext;
            _buildDistributor = buildDistributor;

            _viewModel      = viewModel;
            _solutionEvents = _dte.Events.SolutionEvents;

            Initialize();
        }
예제 #4
0
        public void CancelBuild()
        {
            if (_currentState != BuildState.InProgress || _buildCancelled || _buildCancelledInternally)
            {
                return;
            }

            try
            {
                _packageContext.GetDTE().ExecuteCommand("Build.Cancel");
                _buildCancelledInternally = true;
            }
            catch (Exception ex)
            {
                ex.Trace("Cancel build failed.");
            }
        }
예제 #5
0
        public ToolWindowManager(IPackageContext packageContext)
        {
            _dte = packageContext.GetDTE();
            if (_dte == null)
            {
                throw new InvalidOperationException("Unable to get DTE instance.");
            }

            _windowFrame = (IVsWindowFrame)packageContext.GetToolWindow().Frame;
            if (_windowFrame == null)
            {
                throw new InvalidOperationException("Unable to get IVsWindowFrame instance.");
            }

            _window = GetWindowInstance(packageContext.GetDTE(), typeof(ToolWindow).GUID);
            if (_window == null)
            {
                throw new InvalidOperationException("Unable to get Window instance.");
            }
        }
예제 #6
0
        public BuildContext(IPackageContext packageContext, ControlViewModel viewModel)
        {
            _viewModel                  = viewModel;
            BuildedProjects             = new BuildedProjectsCollection();
            BuildingProjects            = new List <ProjectItem>();
            _buildingProjectsLockObject = ((ICollection)BuildingProjects).SyncRoot;

            _packageContext = packageContext;

            Events dteEvents = packageContext.GetDTE().Events;

            _buildEvents   = dteEvents.BuildEvents;
            _windowEvents  = dteEvents.WindowEvents;
            _commandEvents = dteEvents.CommandEvents;

            _buildEvents.OnBuildBegin           += BuildEvents_OnBuildBegin;
            _buildEvents.OnBuildDone            += (s, e) => BuildEvents_OnBuildDone();
            _buildEvents.OnBuildProjConfigBegin += BuildEvents_OnBuildProjectBegin;
            _buildEvents.OnBuildProjConfigDone  += BuildEvents_OnBuildProjectDone;

            _windowEvents.WindowActivated += WindowEvents_WindowActivated;

            _commandEvents.AfterExecute += CommandEvents_AfterExecute;
        }
예제 #7
0
        public Tool(
            IPackageContext packageContext,
            BuildInfo buildContext, 
            IBuildDistributor buildDistributor, 
            ControlViewModel viewModel)
        {
            _dte = packageContext.GetDTE();
            if (_dte == null)
                throw new InvalidOperationException("Unable to get DTE instance.");

            _dteStatusBar = packageContext.GetStatusBar();
            if (_dteStatusBar == null)
                TraceManager.TraceError("Unable to get IVsStatusbar instance.");

            _toolWindowManager = new ToolWindowManager(packageContext);

            _buildContext = buildContext;
            _buildDistributor = buildDistributor;

            _viewModel = viewModel;
            _solutionEvents = _dte.Events.SolutionEvents;

            Initialize();
        }
예제 #8
0
        public BuildContext(IPackageContext packageContext, FindProjectItemDelegate findProjectItem)
        {
            _buildedProjects = new BuildedProjectsCollection();
            _buildingProjects = new List<ProjectItem>();
            _buildingProjectsLockObject = ((ICollection)_buildingProjects).SyncRoot;

            _packageContext = packageContext;
            _findProjectItem = findProjectItem;

            Events dteEvents = packageContext.GetDTE().Events;
            _buildEvents = dteEvents.BuildEvents;
            _windowEvents = dteEvents.WindowEvents;
            _commandEvents = dteEvents.CommandEvents;

            _buildEvents.OnBuildBegin += BuildEvents_OnBuildBegin;
            _buildEvents.OnBuildDone += (s, e) => BuildEvents_OnBuildDone();
            _buildEvents.OnBuildProjConfigBegin += BuildEvents_OnBuildProjectBegin;
            _buildEvents.OnBuildProjConfigDone += BuildEvents_OnBuildProjectDone;

            _windowEvents.WindowActivated += WindowEvents_WindowActivated;

            _commandEvents.AfterExecute += CommandEvents_AfterExecute;
        }