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:
parent
355b6233cb
commit
bb1bceb8bb
4 changed files with 40 additions and 6 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue