Skip to content

Allow launching file-based apps via dnx - #132008

Draft
jjonescz wants to merge 1 commit into
dotnet:mainfrom
jjonescz:sdk54830-sprint-dnx
Draft

Allow launching file-based apps via dnx#132008
jjonescz wants to merge 1 commit into
dotnet:mainfrom
jjonescz:sdk54830-sprint-dnx

Conversation

@jjonescz

@jjonescz jjonescz commented Aug 7, 2026

Copy link
Copy Markdown
Member

SDK counterpart: dotnet/sdk#55676

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the dnx dispatchers shipped by the installer so that when the first argument looks like a file path and points to a .cs file (or a file with a #! shebang), dnx routes execution to dotnet run --file-mode instead of treating it as a tool invocation.

Changes:

  • Add file-based app detection (path + exists + not directory + .cs or shebang) to the Unix dnx script.
  • Add equivalent file-based app detection to dnx.cmd and route to dotnet run --file-mode with a preserved working directory.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/installer/pkg/sfx/installers/dnx.cmd Adds Windows dispatcher logic to detect file paths and run them via dotnet run --file-mode.
src/installer/pkg/sfx/installers/dnx Adds Unix dispatcher logic to detect file paths and run them via dotnet run --file-mode.

Comment on lines +35 to +43
if [ "$IS_FILE_BASED_APP" = true ]; then
DNX_WORKING_DIRECTORY="$PWD"

if ! cd "$(dirname "$DNX_FILE")"; then
exit 1
fi

exec "$DOTNET" run --file-mode --working-directory "$DNX_WORKING_DIRECTORY" -- "$@"
fi
Comment on lines +35 to +40
:run_file
set "DNX_WORKING_DIRECTORY=%CD%"
pushd "%~dp1" || exit /b 1

"%DOTNET%" run --file-mode --working-directory "%DNX_WORKING_DIRECTORY%" -- %*
set "EXIT_CODE=%ERRORLEVEL%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants