示例#1
0
        private ProjectFileInfo LoadProject(string projectFilePath)
        {
            _logger.LogInformation($"Loading project: {projectFilePath}");

            ProjectFileInfo project;
            var             diagnostics = new List <MSBuildDiagnosticsMessage>();

            try
            {
                project = ProjectFileInfo.Create(projectFilePath, _environment.TargetDirectory, GetSdksPath(projectFilePath), _loggerFactory.CreateLogger <ProjectFileInfo>(), _options, diagnostics);

                if (project == null)
                {
                    _logger.LogWarning($"Failed to load project file '{projectFilePath}'.");
                }
            }
            catch (Exception ex)
            {
                _logger.LogWarning($"Failed to load project file '{projectFilePath}'.", ex);
                _eventEmitter.Error(ex, fileName: projectFilePath);
                project = null;
            }

            _eventEmitter.MSBuildProjectDiagnostics(projectFilePath, diagnostics);

            return(project);
        }