Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Show a friendly message instead of crashing when a solution has no projects - #771

#771
Open
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#771
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

@DanielC000

Copy link
Copy Markdown

Closes #747.

What's wrong

Running dotnet outdated against a solution that references no projects (e.g. one an AI agent scaffolded but hasn't populated yet) crashes with an unhandled System.IO.FileNotFoundException instead of a clean message. Per the reporter:

Unhandled exception. System.IO.FileNotFoundException: Could not find file 'C:\Users\...\AppData\Local\Temp\2zbjhlwk.elv'.
...
   at DotNetOutdated.Core.Services.DependencyGraphService.GenerateDependencyGraphAsync(...)
   at DotNetOutdated.Core.Services.ProjectAnalysisService.AnalyzeProjectAsync(...)

Root cause

When the target solution/project has zero restorable projects, dotnet msbuild ... /t:Restore,GenerateRestoreGraphFile exits successfully but never writes the RestoreGraphOutputPath file (nothing to restore). DependencyGraphService unconditionally read that file on success, so the missing-file read escaped as a raw, unhandled I/O exception.

What changed

DependencyGraphService.GenerateDependencyGraphAsync now checks whether the restore graph file actually exists before reading it, and throws the same CommandValidationException the 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

  • Added test-projects/empty-solution/ (a real .sln with zero project references) + an end-to-end test that runs the CLI against it and asserts a clean exit instead of a crash.
  • Added a unit test in DependencyGraphServiceTests that mocks the MSBuild-succeeds-but-no-output-file case directly.
  • Full suite: 209 tests, 208 passed, 1 pre-existing unrelated skip, 0 failed.
  • Manually reproduced the exact crash from the issue on the pre-fix build, and confirmed the fix replaces it with a friendly message (exit code 1, no stack trace).

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: dotnet-outdated crashes when solution contains no project files

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.