public (MSB.Execution.ProjectInstance projectInstance, ImmutableArray <MSBuildDiagnostic> diagnostics) BuildProject(string filePath) { using (_sdksPathResolver.SetSdksPathEnvironmentVariable(filePath)) { var evaluatedProject = EvaluateProjectFileCore(filePath); SetTargetFrameworkIfNeeded(evaluatedProject); var projectInstance = evaluatedProject.CreateProjectInstance(); var msbuildLogger = new MSBuildLogger(_logger); var buildResult = projectInstance.Build( targets: new string[] { TargetNames.Compile, TargetNames.CoreCompile }, loggers: new[] { msbuildLogger }); var diagnostics = msbuildLogger.GetDiagnostics(); return(buildResult ? (projectInstance, diagnostics) : (null, diagnostics)); } }
public (MSB.Execution.ProjectInstance projectInstance, MSB.Evaluation.Project project, ImmutableArray <MSBuildDiagnostic> diagnostics) BuildProject( string filePath, IReadOnlyDictionary <string, string> configurationsInSolution) { using (_sdksPathResolver.SetSdksPathEnvironmentVariable(filePath)) { var evaluatedProject = EvaluateProjectFileCore(filePath, configurationsInSolution); SetTargetFrameworkIfNeeded(evaluatedProject); var projectInstance = evaluatedProject.CreateProjectInstance(); var msbuildLogger = new MSBuildLogger(_logger); var loggers = new List <MSB.Framework.ILogger>() { msbuildLogger }; if (_options.GenerateBinaryLogs) { var binlogPath = Path.ChangeExtension(projectInstance.FullPath, ".binlog"); var binaryLogger = new MSB.Logging.BinaryLogger() { CollectProjectImports = MSB.Logging.BinaryLogger.ProjectImportsCollectionMode.Embed, Parameters = binlogPath }; loggers.Add(binaryLogger); } var buildResult = projectInstance.Build( targets: new string[] { TargetNames.Compile, TargetNames.CoreCompile }, loggers); var diagnostics = msbuildLogger.GetDiagnostics(); return(buildResult ? (projectInstance, evaluatedProject, diagnostics) : (null, null, diagnostics)); } }