Skip to content

Show specific error message for dotnet <app_path> where app_path is a non-dll/exe file that exists #116940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 7, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 23, 2025

Currently, when a user runs dotnet <app_path> and the host determines that <app_path> is not a runnable app, it's treated as a CLI command and routed to the SDK, which shows a generic error message.

This PR improves the user experience by detecting when the user passes a path to an existing non-dll/exe file and showing a specific error message instead of routing to the SDK.

cc @dotnet/appmodel @AaronRobinsonMSFT

Changes Made

Core Logic Enhancement:

  • Enhanced argument parsing in command_line.cpp to detect the specific scenario:
    • File is not managed (.dll/.exe)
    • Path contains directory separator
    • File exists
    • Not in exec mode
  • Added specific error message for the above

Behavior Change:

Before:

$ dotnet /path/to/config.json
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  You misspelled a built-in dotnet command.
  You intended to execute a .NET program, but dotnet-/path/to/config.json does not exist.
  You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

After:

$ dotnet /path/to/config.json
The application '/path/to/config.json' does not exist or is not a managed .dll or .exe.

Preserves Existing Behavior:

  • Commands without directory separators (like dotnet build) still route to SDK
  • dotnet exec behavior unchanged
  • All existing error codes and messages unchanged

Test Coverage

Added comprehensive tests covering:

  • Absolute paths with directory separators
  • Relative paths like ./subdir/file.txt
  • Commands without separators still route to SDK
  • Backward compatibility verification

All existing tests pass, confirming no regressions.

Fixes #116939.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits June 23, 2025 23:22
… separators

Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Show specific error message for dotnet <app_path> where <app_path> is a non-dll/exe file that exists Show specific error message for dotnet <app_path> where app_path is a non-dll/exe file that exists Jun 23, 2025
Copilot finished work on behalf of elinor-fung June 23, 2025 23:30
@Copilot Copilot AI requested a review from elinor-fung June 23, 2025 23:30
…reporting

Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
@Copilot Copilot AI requested a review from jkotas June 24, 2025 00:14
Copilot finished work on behalf of jkotas June 24, 2025 00:14
…error directly in command_line.cpp

Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
@Copilot Copilot AI requested a review from elinor-fung June 24, 2025 02:03
Copilot finished work on behalf of elinor-fung June 24, 2025 02:03
…tions, remove test file

Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
@Copilot Copilot AI requested a review from elinor-fung June 24, 2025 18:39
Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
@Copilot Copilot AI requested a review from elinor-fung June 25, 2025 00:33
Copilot finished work on behalf of elinor-fung June 25, 2025 00:33
@elinor-fung elinor-fung marked this pull request as ready for review June 25, 2025 22:36
@AnalogFeelings

This comment was marked as spam.

@am11
Copy link
Member

am11 commented Jun 29, 2025

i wonder how much co2 was released into the air just for this

On the bright side, Copilot gets smarter for future PRs. Plus, CO₂ in its supercritical form has some surprising uses, like powering sCO₂ turbines for electricity. So hey, not all doom and gloom on the hippie’s fry! ✌️

@AnalogFeelings

This comment was marked as off-topic.

@am11
Copy link
Member

am11 commented Jun 29, 2025

the temperatures keep rising and carbon capture is a scam to distract the population from the rampant use of polluting technologies, and no, an LLM cannot get "smarter", its a glorified markov chain with no cognitive processes.

Carbon capture has legitimate applications if used alongside real emissions cuts. And LLMs are far beyond Markov chains, they learn complex patterns across context, not just next-word guessing.

Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
@Copilot Copilot AI requested a review from jkotas July 1, 2025 20:32
Copilot finished work on behalf of jkotas July 1, 2025 20:32
Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
@Copilot Copilot AI requested a review from elinor-fung July 2, 2025 00:52
Copilot finished work on behalf of elinor-fung July 2, 2025 00:52
@elinor-fung elinor-fung merged commit 9d6caae into main Jul 7, 2025
156 of 167 checks passed
@elinor-fung elinor-fung deleted the copilot/fix-116939 branch July 7, 2025 18:33
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

Error loading sessions

Retrying...

Successfully merging this pull request may close these issues.

Show specific error message for dotnet <app_path> where <app_path> is a non-dll/exe file that exists
6 participants