Show a friendly message instead of crashing when a solution has no projects - #771
#771Open
DanielC000 wants to merge 1 commit into
dotnet-outdated:masterdotnet-outdated/dotnet-outdated:masterfrom
DanielC000:fix/no-projects-friendly-message-747DanielC000/dotnet-outdated:fix/no-projects-friendly-message-747Copy head branch name to clipboard
Open
Show a friendly message instead of crashing when a solution has no projects#771DanielC000 wants to merge 1 commit intodotnet-outdated:masterdotnet-outdated/dotnet-outdated:masterfrom DanielC000:fix/no-projects-friendly-message-747DanielC000/dotnet-outdated:fix/no-projects-friendly-message-747Copy head branch name to clipboard
DanielC000 wants to merge 1 commit into
dotnet-outdated:masterdotnet-outdated/dotnet-outdated:masterfrom
DanielC000:fix/no-projects-friendly-message-747DanielC000/dotnet-outdated:fix/no-projects-friendly-message-747Copy head branch name to clipboard
Conversation
…ojects When a solution (or project) has no restorable projects, MSBuild's GenerateRestoreGraphFile target reports success but never writes the restore graph output file. dotnet-outdated then tried to read that missing file, surfacing a raw System.IO.FileNotFoundException instead of a clean error (dotnet-outdated#747). DependencyGraphService now checks whether the restore graph file actually exists after a successful run and throws a CommandValidationException with a friendly message when it does not, matching the tool's existing error-reporting style.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #747.
What's wrong
Running
dotnet outdatedagainst a solution that references no projects (e.g. one an AI agent scaffolded but hasn't populated yet) crashes with an unhandledSystem.IO.FileNotFoundExceptioninstead of a clean message. Per the reporter:Root cause
When the target solution/project has zero restorable projects,
dotnet msbuild ... /t:Restore,GenerateRestoreGraphFileexits successfully but never writes theRestoreGraphOutputPathfile (nothing to restore).DependencyGraphServiceunconditionally read that file on success, so the missing-file read escaped as a raw, unhandled I/O exception.What changed
DependencyGraphService.GenerateDependencyGraphAsyncnow checks whether the restore graph file actually exists before reading it, and throws the sameCommandValidationExceptionthe method already uses for the restore-failure branch — which the CLI already catches and reports cleanly — with a new friendly message ("No projects were found to analyze in '{path}'. Make sure the solution references at least one project.").Testing
test-projects/empty-solution/(a real.slnwith zero project references) + an end-to-end test that runs the CLI against it and asserts a clean exit instead of a crash.DependencyGraphServiceTeststhat mocks the MSBuild-succeeds-but-no-output-file case directly.