Example #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);
        }
Example #2
0
        public void Pack(IProjectNode project)
        {
            var hierarchy = project.AsVsHierarchy();

            if (hierarchy != null)
            {
                var targetPackOnBuildFile = Path.Combine(
                    Path.GetDirectoryName(project.PhysicalPath), PackOnBuildFilename);

                // Write the .packonbuild empty file which is used by the targets
                // to override the PackOnBuild property and generate the .nupkg
                if (!File.Exists(targetPackOnBuildFile))
                {
                    File.WriteAllText(targetPackOnBuildFile, string.Empty);
                }

                cleanupFilesOnBuildDone.Add(targetPackOnBuildFile);

                buildManager.StartSimpleUpdateProjectConfiguration(hierarchy, null, null,
                                                                   (uint)(VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_FORCE_UPDATE | VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_BUILD), 0, 0);
            }
        }