public async Task PublishAsync(TextWriter outputPaneWriter, CancellationToken cancellationToken)
        {
            var properties = await GetPropertiesAsync(cancellationToken).ConfigureAwait(false);

            await _buildProject.BuildAsync(
                ImmutableArray.Create(TargetName),
                cancellationToken,
                true,
                properties).ConfigureAwait(false);
        }
Beispiel #2
0
        public async Task <IBuildResult> BuildAsync(string target, IDictionary <string, string> globalProperties)
        {
            if (globalProperties == null)
            {
                globalProperties = new Dictionary <string, string>();
            }

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsOutputWindowPane outputWindowPane = null;
            IVsOutputWindow     outputWindow     = ServiceProvider.GlobalProvider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            if (outputWindow != null)
            {
                outputWindow.GetPane(VSConstants.GUID_BuildOutputWindowPane, out outputWindowPane);
            }

            var hostObjects = new HashSet <IHostObject>();

            ILogger logger = null;

            if (outputWindowPane != null)
            {
                outputWindowPane.Activate();
                logger = new PublishLogger(outputWindowPane);
            }

            var loggers = new HashSet <ILogger>()
            {
                logger
            };

            if (_buildProject == null)
            {
                _buildProject = await GetBuildProject(_hier.GetUnconfiguredProject());
            }

            _hier.GetDTEProject().DTE.Solution.SolutionBuild.BuildProject(globalProperties["Configuration"], _hier.GetDTEProject().UniqueName, true);
            IBuildResult result = await _buildProject?.BuildAsync(new string[] { target }, CancellationToken.None, true, ImmutableDictionary.ToImmutableDictionary(globalProperties), hostObjects.ToImmutableHashSet(), BuildRequestPriority.High, loggers.ToImmutableHashSet());

            return(result);
        }