Beispiel #1
0
        public static ProjectCollection LoadProjectsAndReferences(
            IDictionary <string, string> globalProperties,
            string toolsVersion,
            IBuildEngine buildEngine,
            bool collectStats,
            string projectFullPath,
            IEnumerable <ITaskItem> projectReferences,
            ISlnGenLogger logger)
        {
            // Create an MSBuildProject loader with the same global properties of the project that requested a solution file
            MSBuildProjectLoader projectLoader = new MSBuildProjectLoader(globalProperties, toolsVersion, buildEngine, ProjectLoadSettings.IgnoreMissingImports)
            {
                CollectStats = collectStats,
            };

            logger.LogMessageHigh("Loading project references...");

            ProjectCollection projectCollection = projectLoader.LoadProjectsAndReferences(projectReferences.Select(i => i.GetMetadata("FullPath")).Concat(new[] { projectFullPath }));

            logger.LogMessageNormal($"Loaded {projectCollection.LoadedProjects.Count} project(s)");

            if (collectStats)
            {
                LogStatistics(projectLoader, logger);
            }

            return(projectCollection);
        }
Beispiel #2
0
        public static void LogStatistics(MSBuildProjectLoader projectLoader, ISlnGenLogger logger)
        {
            logger.LogMessageLow("SlnGen Project Evaluation Performance Summary:");

            foreach (KeyValuePair <string, TimeSpan> item in projectLoader.Statistics.ProjectLoadTimes.OrderByDescending(i => i.Value))
            {
                logger.LogMessageLow($"  {Math.Round(item.Value.TotalMilliseconds, 0)} ms  {item.Key}", MessageImportance.Low);
            }
        }