/// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            try
            {
                string localOptInRegKeyVsCurrent = VS14OptInRegKey;
                string localOptInRegKeyVsNext = VS15OptInRegKey;

                // modify the registry key path to account for OS architecture
                if (Environment.Is64BitOperatingSystem == false)
                {
                    localOptInRegKeyVsCurrent = localOptInRegKeyVsCurrent.Replace(@"\WOW6432Node", string.Empty);
                    localOptInRegKeyVsNext = localOptInRegKeyVsNext.Replace(@"\WOW6432Node", string.Empty);
                }

                // check registry for opt in accounting for null values if key doesn't exist
                int? vsCurrentOptIn = (int?)Registry.GetValue(localOptInRegKeyVsCurrent, OptInRegValue, 0);
                int? vsNextOptIn = (int?)Registry.GetValue(localOptInRegKeyVsNext, OptInRegValue, 0);
                int? userOptedIn = vsCurrentOptIn.GetValueOrDefault() + vsNextOptIn.GetValueOrDefault();

                int? microsoftInternalUser = (int?)Registry.GetValue(BuildMonitor.MsftInternalRegKey, BuildMonitor.MsftInternalRegValue, 0);
                microsoftInternalUser = microsoftInternalUser.GetValueOrDefault();

                if (!(userOptedIn == 0 && microsoftInternalUser == 0))
                {
                    DTE dte = GetService(typeof(SDTE)) as DTE;
                    if (dte == null)
                    {
                        throw new InvalidOperationException("No Visual Studio Desktop Environment service (SDTE) available!");
                    }

                    _buildEvents = dte.Events.BuildEvents;
                    _buildEvents.OnBuildBegin += ProcessBuildBeginEvents;
                    _buildEvents.OnBuildDone += ProcessBuildDoneEvents;

                    IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution));
                    if (solution == null)
                    {
                        throw new InvalidOperationException("No Visual Studio Solution service (SVsSolution) available!");
                    }

                    _eventProcessor = new BuildEventProcessor(dte, solution, (microsoftInternalUser != 0));
                }
            }
            catch { }
        }
Exemple #2
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            try
            {
                string localOptInRegKeyVsCurrent = VS14OptInRegKey;
                string localOptInRegKeyVsNext = VS15OptInRegKey;

                // modify the registry key path to account for OS architecture
                if (Environment.Is64BitOperatingSystem == false)
                {
                    localOptInRegKeyVsCurrent = localOptInRegKeyVsCurrent.Replace(@"\WOW6432Node", string.Empty);
                    localOptInRegKeyVsNext = localOptInRegKeyVsNext.Replace(@"\WOW6432Node", string.Empty);
                }

                // check registry for opt in accounting for null values if key doesn't exist
                int? vsCurrentOptIn = (int?)Registry.GetValue(localOptInRegKeyVsCurrent, OptInRegValue, 0);
                int? vsNextOptIn = (int?)Registry.GetValue(localOptInRegKeyVsNext, OptInRegValue, 0);
                int? userOptedIn = vsCurrentOptIn.GetValueOrDefault() + vsNextOptIn.GetValueOrDefault();

                int? microsoftInternalUser = (int?)Registry.GetValue(BuildMonitor.MsftInternalRegKey, BuildMonitor.MsftInternalRegValue, 0);
                microsoftInternalUser = microsoftInternalUser.GetValueOrDefault();

                if (!(userOptedIn == 0 && microsoftInternalUser == 0))
                {
                    DTE dte = GetService(typeof(SDTE)) as DTE;
                    if (dte == null)
                    {
                        throw new InvalidOperationException("No Visual Studio Desktop Environment service (SDTE) available!");
                    }

                    _buildEvents = dte.Events.BuildEvents;
                    _buildEvents.OnBuildBegin += ProcessBuildBeginEvents;
                    _buildEvents.OnBuildDone += ProcessBuildDoneEvents;

                    IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution));
                    if (solution == null)
                    {
                        throw new InvalidOperationException("No Visual Studio Solution service (SVsSolution) available!");
                    }

                    _eventProcessor = new BuildEventProcessor(dte, solution, (microsoftInternalUser != 0));
                }
            }
            catch { }
        }