Exemplo n.º 1
0
        /// <summary>
        /// Builds the solution or project if one is specified.
        /// </summary>
        public async Task <bool> BuildSolutionAsync(BuildAction action = BuildAction.Build)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsSolutionBuildManager svc = await VS.Services.GetSolutionBuildManagerAsync();

            uint buildFlags = (uint)GetBuildFlags(action);

            return(svc.StartSimpleUpdateSolutionConfiguration(buildFlags, 0, 0) == VSConstants.S_OK);
        }
Exemplo n.º 2
0
        private static async Task RebuildSolutionAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            Assumes.Present(_solutionBuildManager);

            var buildFlags = (uint)(VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_BUILD | VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_CLEAN);

            _solutionBuildManager.StartSimpleUpdateSolutionConfiguration(buildFlags, (uint)VSSOLNBUILDQUERYRESULTS.VSSBQR_CONTDEPLOYONERROR_QUERY_NO, 1);
        }
        // ------------------------------------------------------
        /// <summary>
        /// Builds the solution in preparation for a test launch.
        /// </summary>
        public void BuildSolutionToRunTests()
        {
            TryToSetTestResultsText("Building the solution...");

            solutionBuildEvents.BuildingForTestLaunch = true;

            IVsSolutionBuildManager man = (IVsSolutionBuildManager)
                                          GetService(typeof(SVsSolutionBuildManager));

            uint flags = (uint)VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_BUILD;

            uint queryResults = (uint)(
                VSSOLNBUILDQUERYRESULTS.VSSBQR_CONTDEPLOYONERROR_QUERY_NO |
                VSSOLNBUILDQUERYRESULTS.VSSBQR_OUTOFDATE_QUERY_YES |
                VSSOLNBUILDQUERYRESULTS.VSSBQR_SAVEBEFOREBUILD_QUERY_YES);

            int result = man.StartSimpleUpdateSolutionConfiguration(
                flags, queryResults, 1);
        }
        /// <summary>
        /// Builds the solution.
        /// </summary>
        public async Task <bool> BuildSolutionAsync(BuildAction action = BuildAction.Build)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsSolutionBuildManager svc = await VS.Services.GetSolutionBuildManagerAsync();

            uint buildFlags = (uint)GetBuildFlags(action);

            BuildObserver observer = new(null);

            ErrorHandler.ThrowOnFailure(svc.AdviseUpdateSolutionEvents(observer, out uint cookie));

            try
            {
                ErrorHandler.ThrowOnFailure(svc.StartSimpleUpdateSolutionConfiguration(buildFlags, 0, 0));
                return(await observer.Result);
            }
            finally
            {
                svc.UnadviseUpdateSolutionEvents(cookie);
            }
        }