Esempio n. 1
0
        public static async Task RefreshAsync(
            EnvDTE.Project project,
            string projectPath,
            string configId = null,
            IEnumerable <string> selectedFiles = null)
        {
            if (project == null || !QtProjectTracker.IsTracked(projectPath))
            {
                return;
            }
            var tracker = QtProjectTracker.Get(project, projectPath);
            await tracker.Initialized;

            var properties = new Dictionary <string, string>();

            properties["QtVSToolsBuild"] = "true";
            if (selectedFiles != null)
            {
                properties["SelectedFiles"] = string.Join(";", selectedFiles);
            }
            var targets = new List <string> {
                "QtVars"
            };

            if (QtVsToolsPackage.Instance.Options.BuildRunQtTools)
            {
                targets.Add("Qt");
            }

            IEnumerable <string> configs;

            if (configId != null)
            {
                configs = new[] { configId };
            }
            else
            {
                var knownConfigs = await tracker.UnconfiguredProject.Services
                                   .ProjectConfigurationsService.GetKnownProjectConfigurationsAsync();

                configs = knownConfigs.Select(x => x.Name);
            }

            foreach (var config in configs)
            {
                await QtProjectBuild.StartBuildAsync(
                    project, projectPath, config, properties, targets,
                    LoggerVerbosity.Quiet);
            }
        }
Esempio n. 2
0
        public static async Task StartBuildAsync(
            EnvDTE.Project project,
            string projectPath,
            string configName,
            Dictionary <string, string> properties,
            IEnumerable <string> targets,
            LoggerVerbosity verbosity)
        {
            if (project == null)
            {
                throw new ArgumentException("Project cannot be null.");
            }
            if (configName == null)
            {
                throw new ArgumentException("Configuration name cannot be null.");
            }

            RequestTimer.Restart();
            var tracker = QtProjectTracker.Get(project, projectPath);
            await tracker.Initialized;

            if (QtVsToolsPackage.Instance.Options.BuildDebugInformation)
            {
                Messages.Print(string.Format(
                                   "{0:HH:mm:ss.FFF} QtProjectBuild({1}): Request [{2}] {3}",
                                   DateTime.Now, Thread.CurrentThread.ManagedThreadId,
                                   configName, tracker.UnconfiguredProject.FullPath));
            }

            var knownConfigs = await tracker.UnconfiguredProject.Services
                               .ProjectConfigurationsService.GetKnownProjectConfigurationsAsync();

            ConfiguredProject configuredProject = null;

            foreach (var config in knownConfigs)
            {
                var configProject = await tracker.UnconfiguredProject
                                    .LoadConfiguredProjectAsync(config);

                if (configProject.ProjectConfiguration.Name == configName)
                {
                    configuredProject = configProject;
                    break;
                }
            }
            if (configuredProject == null)
            {
                throw new ArgumentException(string.Format("Unknown configuration '{0}'.", configName));
            }

            BuildQueue.Enqueue(new QtProjectBuild()
            {
                Project             = project,
                VcProject           = tracker.VcProject,
                UnconfiguredProject = tracker.UnconfiguredProject,
                ConfiguredProject   = configuredProject,
                Properties          = properties?.ToDictionary(x => x.Key, x => x.Value),
                Targets             = targets?.ToList(),
                LoggerVerbosity     = verbosity
            });
            StaticThreadSafeInit(() => BuildDispatcher,
                                 () => BuildDispatcher = Task.Run(BuildDispatcherLoopAsync))
            .Forget();
        }