When we had a project.json without frameworks, we were failing to show the appropriate error message because when we were generating the error message itself we tried to access the project context (which requires a framework in the PJ). This fix makes the ProjectContext optional to add the migration error.

This commit is contained in:
Livar Cunha 2016-12-08 19:53:35 -08:00
parent 355b6233cb
commit bb1bceb8bb
4 changed files with 40 additions and 6 deletions

View file

@ -55,7 +55,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration
{
new ProjectMigrationReport(
rootSettings.ProjectDirectory,
rootInputs?.DefaultProjectContext.GetProjectName(),
rootInputs?.DefaultProjectContext?.GetProjectName(),
new List<MigrationError> {e.Error},
null)
});
@ -193,7 +193,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration
{
if (!projectContexts.Any())
{
MigrationErrorCodes.MIGRATE1013($"No projects found in {projectDirectory}").Throw();
MigrationErrorCodes.MIGRATE1013($"The project.json specifies no target frameworks in {projectDirectory}").Throw();
}
var defaultProjectContext = projectContexts.First();