Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

Refactors launch profile parsing and adds support for Executable command name.
Fixes environment variable expansion and adds tests.

Copy link
Member

@baronfel baronfel left a comment

Choose a reason for hiding this comment

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

@copilot Good initial attempt, but we can clean this up some. Please address my review comments.

Copilot AI changed the title [WIP] Allow dotnet run to use launch profiles for Executable Add Executable launch profile support to dotnet run and dotnet watch Nov 13, 2025
Copilot AI requested a review from baronfel November 13, 2025 22:53
}

private static ProjectLaunchSettingsModel? TryGetLaunchProfileSettings(string projectDirectory, string projectNameWithoutExtension, string appDesignerFolder, BuildOptions buildOptions, string? profileName)
private static LaunchSettingsModel? TryGetLaunchProfileSettings(string projectDirectory, string projectNameWithoutExtension, string appDesignerFolder, BuildOptions buildOptions, string? profileName)
Copy link
Member

Choose a reason for hiding this comment

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

@dotnet/dotnet-testing if we expand the 'launch settings' handlers that are known, how should the testing experience react? does test support launch settings profiles today?

@tmat tmat force-pushed the copilot/allow-dotnet-run-executable-support branch 2 times, most recently from c6385fe to a602ef8 Compare December 5, 2025 22:29
@tmat tmat force-pushed the copilot/allow-dotnet-run-executable-support branch from a602ef8 to 535b6ae Compare December 10, 2025 02:39
Copilot AI and others added 12 commits December 11, 2025 10:42
- Created base LaunchSettingsModel with ProfileKind discriminator
- Derived ProjectLaunchSettingsModel and ExecutableLaunchSettingsModel
- Added JSON binding models for deserialization
- Updated providers to use JsonSerializer.Deserialize instead of manual traversal
- Exposed SupportedProfileTypes from LaunchSettingsManager
- Updated LaunchSettingsProfile.cs to use array of supported types with comment
- Updated RunCommand to use pattern matching on ProfileKind
- Split Execute method into ExecuteWithProjectProfile and ExecuteWithExecutableProfile
- Updated all method signatures to use base LaunchSettingsModel type

Co-authored-by: baronfel <[email protected]>
Changed hardcoded error message to use CliCommandStrings.LaunchProfileHandlerCannotBeLocated for proper localization support.

Co-authored-by: baronfel <[email protected]>
Simplified argument building logic to make it clearer that ApplicationArgs are properly escaped before being combined with launchSettings.CommandLineArgs. Added comments explaining that CommandLineArgs from JSON cannot be reliably parsed into tokens.

Co-authored-by: baronfel <[email protected]>
Extracted the common code from ExecuteWithProjectProfile and ExecuteWithExecutableProfile into a new ExecuteCommand method. This method handles:
- Applying launch settings to the command
- Applying environment variables from command line
- Sending telemetry
- Setting up Ctrl-C handler
- Executing the command

This reduces code duplication and makes the execution flow clearer.

Co-authored-by: baronfel <[email protected]>
Added tests to verify that the executable command handler correctly applies:
- Environment variables from launch profile
- Working directory settings
- Command line arguments combination (profile + command line)
- Environment variable expansion in executable paths

Created new test assets:
- AppForExecutableProfile: Helper app to verify environment and arguments
- AppWithDetailedExecutableProfile: Test project with various executable profiles

All tests verify the correct application of launch profile settings to the generated command.

Co-authored-by: baronfel <[email protected]>
@tmat tmat force-pushed the copilot/allow-dotnet-run-executable-support branch from 535b6ae to 8bf8f0d Compare December 11, 2025 21:03
Copy link
Member

@MiYanni MiYanni left a comment

Choose a reason for hiding this comment

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

Just a comment on the JSON serialization design but looks good overall.

@tmat tmat requested a review from a team as a code owner December 12, 2025 01:52
@tmat
Copy link
Member

tmat commented Dec 12, 2025

/ba-g WinRT test

@tmat tmat merged commit 554d40c into release/10.0.2xx Dec 12, 2025
22 of 26 checks passed
@tmat tmat deleted the copilot/allow-dotnet-run-executable-support branch December 12, 2025 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Run Issues relating to `dotnet run` Document for new feature Partner request requests from partners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants