コード例 #1
0
        private static void LoadDesignTimeBuildFromBuildLogFile(Package package, FileSystemInfo binLog)
        {
            var projectFile = package.GetProjectFile();

            if (projectFile != null &&
                binLog.LastWriteTimeUtc >= projectFile.LastWriteTimeUtc)
            {
                var manager = new AnalyzerManager();
                var results = manager.Analyze(binLog.FullName);

                if (results.Count == 0)
                {
                    throw new InvalidOperationException("The build log seems to contain no solutions or projects");
                }

                var result = results.FirstOrDefault(p => p.ProjectFilePath == projectFile.FullName);
                if (result != null)
                {
                    package.RoslynWorkspace       = null;
                    package.DesignTimeBuildResult = result;
                    package.LastDesignTimeBuild   = binLog.LastWriteTimeUtc;
                    if (result.Succeeded && !binLog.Name.EndsWith(DesignTimeBuildBinlogFileName))
                    {
                        package.LastSuccessfulBuildTime = binLog.LastWriteTimeUtc;
                        if (package.DesignTimeBuildResult.TryGetWorkspace(out var ws))
                        {
                            package.RoslynWorkspace = ws;
                        }
                    }
                }
            }
        }