public void OnBuildDone(vsBuildScope scope, vsBuildAction action)
 {
     Logger.Write("BuildEvents_OnBuildDone scope: " + scope.ToString() + " action " + action.ToString(), LogLevel.Debug);
     this._currentBuildState = vsBuildState.vsBuildStateDone;
     this.ExecuteIncrement();
     this._updatedItems.Clear();
     BuildVersionIncrementor.ClearSolutionItemAndFileDateCache();
 }
        protected override void Initialize()
        {
            GlobalContext.Properties["package"] = this;
            CheckCommandLine();
            Logger.Initialise(IsCommandLine);
            SettingsCommand.Initialize(this);
            VersionCommand.Initialize(this);

            _buildVersionIncrementor = new BuildVersionIncrementor(this);
            _buildEvents             = DTE.Events.BuildEvents;
            _buildVersionIncrementor.InitializeIncrementors();

            _buildEvents.OnBuildBegin += _buildVersionIncrementor.OnBuildBegin;
            _buildEvents.OnBuildDone  += _buildVersionIncrementor.OnBuildDone;



            base.Initialize();
        }
Example #3
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            GlobalContext.Properties["package"] = this;
            CheckCommandLine();
            Logger.Initialise(IsCommandLine);
            SettingsCommand.Initialize(this);
            VersionCommand.Initialize(this);

            _buildVersionIncrementor = new BuildVersionIncrementor(this);
            _buildEvents             = DTE.Events.BuildEvents;
            _buildVersionIncrementor.InitializeIncrementors();

#pragma warning disable VSTHRD101 // Avoid unsupported async delegates
            _buildEvents.OnBuildBegin += async(s, e) => await _buildVersionIncrementor.OnBuildBeginAsync(s, e);

            _buildEvents.OnBuildDone += async(s, e) => await _buildVersionIncrementor.OnBuildDoneAsync(s, e);

#pragma warning restore VSTHRD101 // Avoid unsupported async delegates
        }
 public BuildVersionIncrementor(Connect connect)
 {
     this._connect = connect;
     BuildVersionIncrementor._instance = this;
 }
        private bool IsProjectModified(Project project, LanguageType language)
        {
            bool result;

            try
            {
                Logger.Write(string.Format("Checking project '{0}'...", project.Name), LogLevel.Debug);
                string outputFileName;
                string text;
                try
                {
                    Configuration activeConfiguration = project.ConfigurationManager.ActiveConfiguration;
                    outputFileName = project.Properties.Item("OutputFileName").Value.ToString();
                    text           = project.Properties.Item("FullPath").Value.ToString();
                    text           = Path.Combine(text, activeConfiguration.Properties.Item("OutputPath").Value.ToString());
                }
                catch
                {
                    try
                    {
                        object @object = project.Properties.Item("project").Object;
                        object obj     = @object.GetType().InvokeMember("Configurations", BindingFlags.GetProperty, null, @object, null);
                        object obj2    = obj.GetType().InvokeMember("Item", BindingFlags.InvokeMethod, null, obj, new object[]
                        {
                            1
                        });
                        string path = "";
                        if (obj2 != null)
                        {
                            path = (string)obj2.GetType().InvokeMember("PrimaryOutput", BindingFlags.GetProperty, null, obj2, null);
                        }
                        outputFileName = Path.GetFileName(path);
                        text           = Path.GetDirectoryName(path);
                        if (!text.EndsWith(Path.DirectorySeparatorChar.ToString()))
                        {
                            text += Path.DirectorySeparatorChar;
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Write(string.Format("Could not get project output file date: {0}. Assumming file is modified.", ex.Message), LogLevel.Warning);
                        result = true;
                        return(result);
                    }
                }
                DateTime cachedFileDate = BuildVersionIncrementor.GetCachedFileDate(outputFileName, text);
                foreach (ProjectItem projectItem in project.ProjectItems)
                {
                    if (projectItem.Kind == "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}" || projectItem.Kind == "{6BB5F8F0-4483-11D3-8BCF-00C04F8EC28C}")
                    {
                        foreach (ProjectItem item in projectItem.ProjectItems)
                        {
                            if (this.CheckProjectItem(item, cachedFileDate))
                            {
                                Logger.Write(string.Format("Project's ('{0}') item '{1}' is modified. Version will be updated.", project.Name, projectItem.Name), LogLevel.Debug);
                                result = true;
                                return(result);
                            }
                        }
                    }
                    else
                    {
                        if (this.CheckProjectItem(projectItem, cachedFileDate))
                        {
                            Logger.Write(string.Format("Project's ('{0}') item '{1}' is modified. Version will be updated.", project.Name, projectItem.Name), LogLevel.Debug);
                            result = true;
                            return(result);
                        }
                    }
                }
                Logger.Write(string.Format("Project '{0}' is not modified", project.Name), LogLevel.Debug);
                result = false;
            }
            catch (Exception ex)
            {
                Logger.Write(string.Format("Could not check if project were modified because: {0}. Assumming file is modified.", ex.Message), LogLevel.Warning);
                Logger.Write(ex.ToString(), LogLevel.Debug);
                result = true;
            }
            return(result);
        }
 public Connect()
 {
     this._logger = new Logger(this);
     this._incrementor = new BuildVersionIncrementor(this);
 }
 public Connect()
 {
     this._logger      = new Logger(this);
     this._incrementor = new BuildVersionIncrementor(this);
 }
 public BuildVersionIncrementor(Connect connect)
 {
     this._connect = connect;
     BuildVersionIncrementor._instance = this;
 }