Esempio n. 1
0
        protected override async Task <bool> TryHandleCommandAsync(IProjectTree node, bool focused, long commandExecuteOptions, IntPtr variantArgIn, IntPtr variantArgOut)
        {
            if (!ShouldHandle(node))
            {
                return(false);
            }

            if (await IsReadyToBuildAsync().ConfigureAwait(false))
            {
                // Build manager APIs require UI thread access.
                await _threadingService.SwitchToUIThread();

                // Save documents before build.
                var projectVsHierarchy = (IVsHierarchy)Project.Services.HostObject;
                ErrorHandler.ThrowOnFailure(_buildManager.SaveDocumentsBeforeBuild(projectVsHierarchy, (uint)VSConstants.VSITEMID.Root, 0 /*docCookie*/));

                // Enable generating package on build ("GeneratePackageOnBuild") for all projects being built.
                _generatePackageOnBuildPropertyProvider.OverrideGeneratePackageOnBuild(true);

                // Kick off the build.
                uint dwFlags = (uint)(VSSOLNBUILDUPDATEFLAGS.SBF_SUPPRESS_SAVEBEFOREBUILD_QUERY | VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_BUILD);
                ErrorHandler.ThrowOnFailure(_buildManager.StartSimpleUpdateProjectConfiguration(projectVsHierarchy, null, null, dwFlags, 0, 0));
            }

            return(true);
        }
Esempio n. 2
0
        public static bool RunCloneDetective(EventHandler <CloneDetectiveCompletedEventArgs> completedHandler)
        {
            string solutionPath = VSPackage.Instance.GetSolutionPath();

            // Save all modified documents before we start the build. Pay attention
            // to the fact that the user can cancel this operation.
            IVsSolutionBuildManager2 solutionBuildManager = (IVsSolutionBuildManager2)VSPackage.Instance.GetService(typeof(SVsSolutionBuildManager));
            int hr = solutionBuildManager.SaveDocumentsBeforeBuild(null, 0, 0);

            if (hr == VSConstants.E_ABORT)
            {
                return(false);
            }

            VSPackage.Instance.ClearOutput();

            _cloneDetectiveRunner            = new CloneDetectiveRunner(solutionPath);
            _cloneDetectiveRunner.Started   += (sender, e) => WriteStartedMessage(e);
            _cloneDetectiveRunner.Message   += (sender, e) => WriteOutputMessage(e);
            _cloneDetectiveRunner.Completed += (sender, e) =>
            {
                WriteCompletedMessage(e);

                _cloneDetectiveRunner = null;

                if (e.Result != null)
                {
                    CloneDetectiveResult = e.Result;
                }

                completedHandler(sender, e);
            };

            // Validate path to ConQAT.bat
            if (!File.Exists(GlobalSettings.GetConqatBatFileName()))
            {
                VSPackage.Instance.ShowError(Res.InvalidConqatBatPath);
                return(false);
            }

            // Validate Java Home.
            if (!File.Exists(Path.Combine(Path.Combine(GlobalSettings.GetJavaHome(), "bin"), "Java.exe")))
            {
                VSPackage.Instance.ShowError(Res.InvalidJavaExePath);
                return(false);
            }

            // Now run the clone detective.
            _cloneDetectiveRunner.RunAsync();

            return(true);
        }
Esempio n. 3
0
 private bool SaveAllOpenFiles()
 {
     try
     {
         IVsSolutionBuildManager2 service = this.ServiceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;
         if (service != null)
         {
             ErrorHandler.ThrowOnFailure(service.SaveDocumentsBeforeBuild(null, 0xfffffffe, 0));
         }
     }
     catch (COMException exception)
     {
         if ((exception.ErrorCode != -2147467260) && (exception.ErrorCode != -2147221492))
         {
             throw;
         }
         return(true);
     }
     return(false);
 }
Esempio n. 4
0
 private void SaveAllDocumentsBeforeBuild()
 {
     if ((_dte != null) && (_dte.Solution != null) && (_dte.Solution.Projects != null))
     {
         uint itemid = 0xfffffffe;
         try
         {
             IVsSolutionBuildManager2 manager = _serviceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;
             if (manager != null)
             {
                 manager.SaveDocumentsBeforeBuild(null, itemid, 0);
             }
         }
         catch (COMException exception)
         {
             if ((exception.ErrorCode != -2147467260) && (exception.ErrorCode != -2147221492))
             {
                 throw;
             }
             return;
         }
     }
     System.Windows.Forms.Application.DoEvents();
 }