Skip to content

Commit

Permalink
PMC Tools: Throw a better exception when ActiveConfiguration returns …
Browse files Browse the repository at this point in the history
…null (#22334)

Part of #16386
  • Loading branch information
bricelam authored Aug 31, 2020
1 parent b87a5fb commit e0f9cee
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/EFCore.Tools/tools/EntityFrameworkCore.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,16 @@ function EF($project, $startupProject, $params, $applicationArgs, [switch] $skip
Write-Host 'Build succeeded.'
}

$activeConfiguration = $startupProject.ConfigurationManager.ActiveConfiguration
if ($activeConfiguration -eq $null)
{
throw "Unable to read project configuration settings of project '$($startupProject.ProjectName)' for the " +
'active solution configuration. Try closing Package Manager Console and restarting Visual Studio. If the ' +
'problem persists, use Help > Send Feedback > Report a Problem.'
}

$startupProjectDir = GetProperty $startupProject.Properties 'FullPath'
$outputPath = GetProperty $startupProject.ConfigurationManager.ActiveConfiguration.Properties 'OutputPath'
$outputPath = GetProperty $activeConfiguration.Properties 'OutputPath'
$targetDir = [IO.Path]::GetFullPath([IO.Path]::Combine($startupProjectDir, $outputPath))
$startupTargetFileName = GetProperty $startupProject.Properties 'OutputFileName'
$startupTargetPath = Join-Path $targetDir $startupTargetFileName
Expand Down

0 comments on commit e0f9cee

Please sign in to comment.