private void UpdateProject(SolutionItem solutionItem)
 {
     if (GlobalIncrementSettings.ApplySettings == GlobalIncrementSettings.ApplyGlobalSettings.Always || solutionItem.IncrementSettings.UseGlobalSettings)
     {
         solutionItem.ApplyGlobalSettings();
     }
     if (!this._updatedItems.ContainsKey(solutionItem.UniqueName))
     {
         if (this.ActiveConfigurationMatch(solutionItem))
         {
             if (solutionItem.IncrementSettings.AutoUpdateAssemblyVersion)
             {
                 this.Update(solutionItem, "AssemblyVersion");
             }
             if (solutionItem.IncrementSettings.AutoUpdateFileVersion)
             {
                 this.Update(solutionItem, "AssemblyFileVersion");
             }
         }
         try
         {
             if (solutionItem.BuildDependency != null)
             {
                 object[] array  = (object[])solutionItem.BuildDependency.RequiredProjects;
                 object[] array2 = array;
                 for (int i = 0; i < array2.Length; i++)
                 {
                     object       obj           = array2[i];
                     SolutionItem solutionItem2 = SolutionItem.ConstructSolutionItem(this._connect, (Project)obj, false);
                     if (solutionItem2 != null)
                     {
                         try
                         {
                             this.UpdateProject(solutionItem2);
                         }
                         catch (Exception ex)
                         {
                             Logger.Write(string.Concat(new string[]
                             {
                                 "Exception occured while updating project dependency \"",
                                 solutionItem2.UniqueName,
                                 "\" for \"",
                                 solutionItem.UniqueName,
                                 "\".\n",
                                 ex.Message
                             }), LogLevel.Error);
                         }
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Logger.Write("Failed updating dependencies for \"" + solutionItem.UniqueName + "\".\n" + ex.Message, LogLevel.Error);
         }
         this._updatedItems.Add(solutionItem.UniqueName, solutionItem);
     }
 }
        private void UpdateProject(SolutionItem solutionItem)
        {
            if (GlobalIncrementSettings.ApplySettings == GlobalIncrementSettings.ApplyGlobalSettings.Always ||
                solutionItem.IncrementSettings.UseGlobalSettings)
            {
                solutionItem.ApplyGlobalSettings();
            }

            if (_updatedItems.ContainsKey(solutionItem.UniqueName))
            {
                return;
            }

            if (ActiveConfigurationMatch(solutionItem))
            {
                if (solutionItem.IncrementSettings.AutoUpdateAssemblyVersion)
                {
                    Update(solutionItem, Constants.ATTRIBUTE_ASSEMBLY_VERSION);
                }

                if (solutionItem.IncrementSettings.AutoUpdateFileVersion)
                {
                    Update(solutionItem, Constants.ATTRIBUTE_ASSEMBLY_FILE_VERSION);
                }
            }

            try
            {
                if (solutionItem.BuildDependency != null)
                {
                    var references = (object[])solutionItem.BuildDependency.RequiredProjects;

                    foreach (var dep in
                             references.Select(o => SolutionItem.ConstructSolutionItem(_package, (Project)o, false))
                             .Where(dep => dep != null))
                    {
                        try
                        {
                            UpdateProject(dep);
                        }
                        catch (Exception ex)
                        {
                            Logger.Write(
                                $"Exception occured while updating project dependency \"{dep.UniqueName}\" for \"{solutionItem.UniqueName}\".\n{ex.Message}",
                                LogLevel.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write($"Failed updating dependencies for \"{solutionItem.UniqueName}\".\n{ex.Message}",
                             LogLevel.Error);
            }

            _updatedItems.Add(solutionItem.UniqueName, solutionItem);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates build version for the given project and it's dependencies.
        /// </summary>
        /// <param name="solutionItem">The solution item.</param>
        private void UpdateProject(SolutionItem solutionItem)
        {
            //if we should apply them, we will...I don't care if it is a solution or a project
            if (solutionItem.IncrementSettings.UseGlobalSettings)
            {
                solutionItem.ApplyGlobalSettings();
            }

            if (_updatedItems.ContainsKey(solutionItem.UniqueName))
            {
                return;
            }

            if (ActiveConfigurationMatch(solutionItem))
            {
                if (solutionItem.IncrementSettings.AutoUpdateAssemblyVersion)
                {
                    Update(solutionItem, "AssemblyVersion");
                }

                if (solutionItem.IncrementSettings.AutoUpdateFileVersion)
                {
                    Update(solutionItem, "AssemblyFileVersion");
                }
            }

            try
            {
                if (solutionItem.BuildDependency != null)
                {
                    object[] references = (object[])solutionItem.BuildDependency.RequiredProjects;

                    foreach (object o in references)
                    {
                        SolutionItem dep = SolutionItem.ConstructSolutionItem(_connect, (Project)o, false);

                        if (dep != null)
                        {
                            try
                            {
                                UpdateProject(dep);
                            }
                            catch (Exception ex)
                            {
                                Logger.Write("Exception occured while updating project dependency \"" + dep.UniqueName + "\" for \"" + solutionItem.UniqueName + "\".\n" + ex.Message, LogLevel.Error);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Failed updating dependencies for \"" + solutionItem.UniqueName + "\".\n" + ex.Message, LogLevel.Error);
            }

            _updatedItems.Add(solutionItem.UniqueName, solutionItem);
        }
Ejemplo n.º 4
0
 private static void FillSolutionTree(Connect connect, SolutionItem solutionItem, ProjectItems projectItems)
 {
     if (projectItems != null)
     {
         foreach (ProjectItem projectItem in projectItems)
         {
             SolutionItem solutionItem2 = SolutionItem.ConstructSolutionItem(connect, projectItem.SubProject);
             if (solutionItem2 != null)
             {
                 solutionItem.SubItems.Add(solutionItem2);
             }
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Execute increment
        /// </summary>
        private void ExecuteIncrement()
        {
            if (!GlobalAddinSettings.Default.IsEnabled)
            {
                Logger.Write("BuildVersionIncrement disabled.", LogLevel.Info);
                return;
            }
            try
            {
                if (_currentBuildAction == vsBuildAction.vsBuildActionBuild ||
                    _currentBuildAction == vsBuildAction.vsBuildActionRebuildAll)
                {
                    if (_currentBuildScope == vsBuildScope.vsBuildScopeSolution)
                    {
                        // Solution level ...

                        Solution     solution     = _connect.ApplicationObject.Solution;
                        SolutionItem solutionItem = new SolutionItem(_connect, solution, true);
                        UpdateRecursive(solutionItem);
                    }
                    else
                    {
                        // Grab the active project and check all depencies
                        Array projects = (Array)_connect.ApplicationObject.ActiveSolutionProjects;
                        foreach (Project p in projects)
                        {
                            SolutionItem solutionItem = SolutionItem.ConstructSolutionItem(_connect, p, false);

                            if (solutionItem != null)
                            {
                                // Do not take any action if current solution item is
                                // not modified - just do not waste time for unchanged projects
                                if (IsSolutionItemModified(solutionItem))
                                {
                                    UpdateProject(solutionItem);
                                }
                            }
                        } // foreach
                    }     // else

                    Logger.Write(string.Format("{0}-build process : Completed",
                                               _currentBuildState == vsBuildState.vsBuildStateInProgress ? "Pre" : "Post"), LogLevel.Info);
                } // if
            }     // try
            catch (Exception ex)
            {
                Logger.Write("Error occured while executing build version increment.\n" + ex.ToString(), LogLevel.Error);
            }
        } // ExecuteIncrement
Ejemplo n.º 6
0
        private async System.Threading.Tasks.Task ExecuteIncrementAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            if (!Settings.Default.IsEnabled)
            {
                Logger.Write("BuildVersionIncrement disabled.");
                return;
            }
            try
            {
                var dte = await GetDTEAsync();

                if (_currentBuildAction != vsBuildAction.vsBuildActionBuild &&
                    _currentBuildAction != vsBuildAction.vsBuildActionRebuildAll)
                {
                    return;
                }
                if (_currentBuildScope == vsBuildScope.vsBuildScopeSolution)
                {
                    var solution     = dte.Solution;
                    var solutionItem = new SolutionItem(_package, solution, true);
                    await UpdateRecursiveAsync(solutionItem);
                }
                else
                {
                    var projects = (Array)dte.ActiveSolutionProjects;
                    foreach (var solutionItem in from Project p in projects
                             select SolutionItem.ConstructSolutionItem(_package, p, false)
                             into solutionItem
                             where solutionItem != null
                             where IsSolutionItemModified(solutionItem)
                             select solutionItem)
                    {
                        await UpdateProjectAsync(solutionItem);
                    }
                }

                Logger.Write(
                    $"{(_currentBuildState == vsBuildState.vsBuildStateInProgress ? "Pre" : "Post")}-build process : Completed");
            }
            catch (Exception ex)
            {
                Logger.Write("Error occured while executing build version increment.\n" + ex, LogLevel.Error);
            }
        }
Ejemplo n.º 7
0
        private void ExecuteIncrement()
        {
            if (!GlobalAddinSettings.Default.IsEnabled)
            {
                Logger.Write("BuildVersionIncrement disabled.", LogLevel.Debug);
                return;
            }

            try
            {
                if (_currentBuildAction == vsBuildAction.vsBuildActionBuild ||
                    _currentBuildAction == vsBuildAction.vsBuildActionRebuildAll)
                {
                    if (_currentBuildScope == vsBuildScope.vsBuildScopeSolution)
                    {
                        // Solution level ...

                        Solution solution = _connect.ApplicationObject.Solution;

                        SolutionItem solutionItem = new SolutionItem(_connect, solution, true);
                        UpdateRecursive(solutionItem);
                    }
                    else
                    {
                        // Grab the active project and check all depencies
                        Array projects = (Array)_connect.ApplicationObject.ActiveSolutionProjects;
                        foreach (Project p in projects)
                        {
                            SolutionItem solutionItem = SolutionItem.ConstructSolutionItem(_connect, p, false);

                            if (solutionItem != null)
                            {
                                UpdateProject(solutionItem);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Error occured while executing build version increment.\n" + ex.ToString(), LogLevel.Error);
            }
        }
        private void ExecuteIncrement()
        {
            if (!Settings.Default.IsEnabled)
            {
                Logger.Write("BuildVersionIncrement disabled.");
                return;
            }
            try
            {
                if (_currentBuildAction != vsBuildAction.vsBuildActionBuild &&
                    _currentBuildAction != vsBuildAction.vsBuildActionRebuildAll)
                {
                    return;
                }
                if (_currentBuildScope == vsBuildScope.vsBuildScopeSolution)
                {
                    var solution     = DTE.Solution;
                    var solutionItem = new SolutionItem(_package, solution, true);
                    UpdateRecursive(solutionItem);
                }
                else
                {
                    var projects = (Array)DTE.ActiveSolutionProjects;
                    foreach (var solutionItem in from Project p in projects
                             select SolutionItem.ConstructSolutionItem(_package, p, false)
                             into solutionItem
                             where solutionItem != null
                             where IsSolutionItemModified(solutionItem)
                             select solutionItem)
                    {
                        UpdateProject(solutionItem);
                    }
                }

                Logger.Write(
                    $"{(_currentBuildState == vsBuildState.vsBuildStateInProgress ? "Pre" : "Post")}-build process : Completed");
            }
            catch (Exception ex)
            {
                Logger.Write("Error occured while executing build version increment.\n" + ex, LogLevel.Error);
            }
        }
 private void ExecuteIncrement()
 {
     if (!GlobalAddinSettings.Default.IsEnabled)
     {
         Logger.Write("BuildVersionIncrement disabled.", LogLevel.Info);
     }
     else
     {
         try
         {
             if (this._currentBuildAction == vsBuildAction.vsBuildActionBuild || this._currentBuildAction == vsBuildAction.vsBuildActionRebuildAll)
             {
                 if (this._currentBuildScope == vsBuildScope.vsBuildScopeSolution)
                 {
                     Solution     solution     = this._connect.ApplicationObject.Solution;
                     SolutionItem solutionItem = new SolutionItem(this._connect, solution, true);
                     this.UpdateRecursive(solutionItem);
                 }
                 else
                 {
                     Array array = (Array)this._connect.ApplicationObject.ActiveSolutionProjects;
                     foreach (Project project in array)
                     {
                         SolutionItem solutionItem = SolutionItem.ConstructSolutionItem(this._connect, project, false);
                         if (solutionItem != null && this.IsSolutionItemModified(solutionItem))
                         {
                             this.UpdateProject(solutionItem);
                         }
                     }
                 }
                 Logger.Write(string.Format("{0}-build process : Completed", (this._currentBuildState == vsBuildState.vsBuildStateInProgress) ? "Pre" : "Post"), LogLevel.Info);
             }
         }
         catch (Exception ex)
         {
             Logger.Write("Error occured while executing build version increment.\n" + ex.ToString(), LogLevel.Error);
         }
     }
 }
Ejemplo n.º 10
0
        private async System.Threading.Tasks.Task UpdateProjectAsync(SolutionItem solutionItem)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            if (GlobalIncrementSettings.ApplySettings == GlobalIncrementSettings.ApplyGlobalSettings.Always ||
                solutionItem.IncrementSettings.UseGlobalSettings)
            {
                solutionItem.ApplyGlobalSettings();
            }

            if (_updatedItems.ContainsKey(solutionItem.UniqueName))
            {
                return;
            }

            if (ActiveConfigurationMatch(solutionItem))
            {
                if (solutionItem.IncrementSettings.AutoUpdateAssemblyVersion)
                {
                    await UpdateAsync(solutionItem, Constants.ATTRIBUTE_ASSEMBLY_VERSION);
                }

                if (solutionItem.IncrementSettings.AutoUpdateFileVersion)
                {
                    await UpdateAsync(solutionItem, Constants.ATTRIBUTE_ASSEMBLY_FILE_VERSION);
                }
            }

            try
            {
                if (solutionItem.BuildDependency != null)
                {
                    var references = (object[])solutionItem.BuildDependency.RequiredProjects;

                    foreach (var dep in
                             references.Select(o => { ThreadHelper.ThrowIfNotOnUIThread(); return(SolutionItem.ConstructSolutionItem(_package, (Project)o, false)); })
                             .Where(dep => dep != null))
                    {
                        try
                        {
                            await UpdateProjectAsync(dep);
                        }
                        catch (Exception ex)
                        {
                            Logger.Write(
                                $"Exception occured while updating project dependency \"{dep.UniqueName}\" for \"{solutionItem.UniqueName}\".\n{ex.Message}",
                                LogLevel.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write($"Failed updating dependencies for \"{solutionItem.UniqueName}\".\n{ex.Message}",
                             LogLevel.Error);
            }

            _updatedItems.Add(solutionItem.UniqueName, solutionItem);
        }
Ejemplo n.º 11
0
 public static SolutionItem ConstructSolutionItem(Connect connect, Project project)
 {
     return(SolutionItem.ConstructSolutionItem(connect, project, true));
 }