Exemple #1
0
        private void BuildEvents_OnBuildDone()
        {
            if (_buildAction == vsBuildAction.vsBuildActionDeploy)
            {
                return;
            }

            if (_currentState != BuildState.InProgress)
            {
                // Start command (F5), when Build is not required.
                return;
            }

            _buildProcessCancellationToken.Cancel();

            _buildedSolution  = _buildingSolution;
            _buildingSolution = null;

            lock (_buildingProjectsLockObject)
            {
                _buildingProjects.Clear();
            }

            _buildFinishTime = DateTime.Now;
            _currentState    = BuildState.Done;

            OnBuildDone(this, EventArgs.Empty);
        }
        private void BuildEvents_OnBuildDone()
        {
            if (_buildAction == vsBuildAction.vsBuildActionDeploy)
                return;

            if (_currentState != BuildState.InProgress)
            {
                // Start command (F5), when Build is not required.
                return;
            }

            _buildProcessCancellationToken.Cancel();

            _buildedSolution = _buildingSolution;
            _buildingSolution = null;

            lock (_buildingProjectsLockObject)
            {
                _buildingProjects.Clear();
            }

            _buildFinishTime = DateTime.Now;
            _currentState = BuildState.Done;

            OnBuildDone(this, EventArgs.Empty);
        }
        private void BuildEvents_OnBuildBegin(vsBuildScope scope, vsBuildAction action)
        {
            if (action == vsBuildAction.vsBuildActionDeploy)
                return;

            RegisterLogger();

            _currentState = BuildState.InProgress;

            _buildStartTime = DateTime.Now;
            _buildFinishTime = null;
            _buildAction = action;

            switch (scope)
            {
                case vsBuildScope.vsBuildScopeSolution:
                case vsBuildScope.vsBuildScopeBatch:
                case vsBuildScope.vsBuildScopeProject:
                    _buildScope = scope;
                    break;

                case 0:
                    // Scope may be 0 in case of Clean solution, then Start (F5).
                    _buildScope = vsBuildScope.vsBuildScopeSolution;
                    break;

                default:
                    throw new ArgumentOutOfRangeException("scope");
            }

            if (scope == vsBuildScope.vsBuildScopeProject)
            {
                var projContext = _activeProjectContext;
                switch (projContext.Type)
                {
                    case vsWindowType.vsWindowTypeSolutionExplorer:
                        ////var solutionExplorer = (UIHierarchy)dte.Windows.Item(Constants.vsext_wk_SProjectWindow).Object;
                        var solutionExplorer = (UIHierarchy)projContext.Object;
                        var items = (Array)solutionExplorer.SelectedItems;
                        switch (items.Length)
                        {
                            case 0:
                                TraceManager.TraceError("Unable to get target projects in Solution Explorer (vsBuildScope.vsBuildScopeProject)");
                                _buildScopeProject = null;
                                break;

                            case 1:
                                var item = (UIHierarchyItem)items.GetValue(0);
                                _buildScopeProject = (Project)item.Object;
                                break;

                            default:
                                _buildScopeProject = null;
                                break;
                        }
                        break;

                    case vsWindowType.vsWindowTypeDocument:
                        _buildScopeProject = projContext.Project;
                        break;

                    default:
                        throw new InvalidOperationException("Unsupported type of active project context for vsBuildScope.vsBuildScopeProject.");
                }
            }

            _buildCancelled = false;
            _buildCancelledInternally = false;

            _buildedProjects.Clear();
            lock (_buildingProjectsLockObject)
            {
                _buildingProjects.Clear();
            }

            _buildedSolution = null;
            _buildingSolution = new BuildedSolution(_packageContext.GetDTE().Solution);

            OnBuildBegin(this, EventArgs.Empty);

            _buildProcessCancellationToken = new CancellationTokenSource();
            Task.Factory.StartNew(BuildEvents_BuildInProcess,
                                    _buildProcessCancellationToken.Token,
                                    _buildProcessCancellationToken.Token);
        }
Exemple #4
0
        private void BuildEvents_OnBuildBegin(vsBuildScope scope, vsBuildAction action)
        {
            if (action == vsBuildAction.vsBuildActionDeploy)
            {
                return;
            }

            RegisterLogger();

            _currentState = BuildState.InProgress;

            _buildStartTime  = DateTime.Now;
            _buildFinishTime = null;
            _buildAction     = action;

            switch (scope)
            {
            case vsBuildScope.vsBuildScopeSolution:
            case vsBuildScope.vsBuildScopeBatch:
            case vsBuildScope.vsBuildScopeProject:
                _buildScope = scope;
                break;

            case 0:
                // Scope may be 0 in case of Clean solution, then Start (F5).
                _buildScope = vsBuildScope.vsBuildScopeSolution;
                break;

            default:
                throw new ArgumentOutOfRangeException("scope");
            }

            if (scope == vsBuildScope.vsBuildScopeProject)
            {
                var projContext = _activeProjectContext;
                switch (projContext.Type)
                {
                case vsWindowType.vsWindowTypeSolutionExplorer:
                    ////var solutionExplorer = (UIHierarchy)dte.Windows.Item(Constants.vsext_wk_SProjectWindow).Object;
                    var solutionExplorer = (UIHierarchy)projContext.Object;
                    var items            = (Array)solutionExplorer.SelectedItems;
                    switch (items.Length)
                    {
                    case 0:
                        TraceManager.TraceError("Unable to get target projects in Solution Explorer (vsBuildScope.vsBuildScopeProject)");
                        _buildScopeProject = null;
                        break;

                    case 1:
                        var item = (UIHierarchyItem)items.GetValue(0);
                        _buildScopeProject = (Project)item.Object;
                        break;

                    default:
                        _buildScopeProject = null;
                        break;
                    }
                    break;

                case vsWindowType.vsWindowTypeDocument:
                    _buildScopeProject = projContext.Project;
                    break;

                default:
                    throw new InvalidOperationException("Unsupported type of active project context for vsBuildScope.vsBuildScopeProject.");
                }
            }

            _buildCancelled           = false;
            _buildCancelledInternally = false;

            _buildedProjects.Clear();
            lock (_buildingProjectsLockObject)
            {
                _buildingProjects.Clear();
            }

            _buildedSolution  = null;
            _buildingSolution = new BuildedSolution(_packageContext.GetDTE().Solution);

            OnBuildBegin(this, EventArgs.Empty);

            _buildProcessCancellationToken = new CancellationTokenSource();
            Task.Factory.StartNew(BuildEvents_BuildInProcess,
                                  _buildProcessCancellationToken.Token,
                                  _buildProcessCancellationToken.Token);
        }