8000 Support launchSettings.json workingDirectory with dotnet run by skybaks · Pull Request #42534 · dotnet/sdk · GitHub
[go: up one dir, main page]

Skip to content

Support launchSettings.json workingDirectory with dotnet run #42534

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

skybaks
Copy link
@skybaks skybaks commented Aug 5, 2024

This change adds support for the workingDirectory field of the launchSettings.json file to the dotnet run command. I believe this should also resolve #20885.

I followed the behavior of how commandLineArgs interacts with RunArguments in the project file where if RunArguments is defined then it overrides whatever is defined in the launchSettings.json.
In the same way, if RunWorkingDirectory is defined in the project file, it will override the workingDirectory in the launchSettings.json. The tests I added should confirm that behavior.

@ghost ghost added Area-CLI untriaged Request triage from a team member labels Aug 5, 2024
@skybaks
Copy link
Author
skybaks commented Aug 5, 2024

@dotnet-policy-service agree

@@ -73,6 +73,10 @@ public int Execute()
{
targetCommand.SetCommandArgs(launchSettings.CommandLineArgs);
}
if (string.IsNullOrEmpty(targetCommand.CommandWorkingDirectory) && launchSettings.WorkingDirectory != null)
Copy link
Member

Choose a reason for hiding this comment

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

Triage: We think that the launch profile should always override the value from the project as letting customers control this with different launch profiles is thee experience we would want. Mind removing the isnullorempty check here and on line 72 to make the command line args consistent.

Copy link
Author

Choose a reason for hiding this comment

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

I don't mind making that change but in doing so I realized that the implementation of commandLineArgs is a little more nuanced than I originally assumed.

Currently, the arguments are either:

  • RunArguments project setting + CLI arguments
    OR if neither of those are set
  • launchSettings.json commandLineArgs

If I flatly remove the isnullorempty check from line 72 then the RunArguments project setting will be overwritten, but it will also override any CLI arguments which does not seem like desirable behavior.

I could add a check to allow CLI arguments to override launchSettings.json arguments, or I could just concatenate the launchSettings.json arguments with the CLI arguments in the same way as they are being handled with the RunArguments project setting now.

I'm leaning more toward the second option which, if implemented, would change the argument behavior to:

  • RunArguments project setting + CLI arguments
    OR if launchSettings.json commandLineArgs exists
  • launchSettings.json commandLineArgs + CLI arguments

Copy link
Member

Choose a reason for hiding this comment

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

Triage: Good catch on the command args. I guess those should be left as is. For the current working directory though, we still think we should always override. CC @baronfel

@skybaks skybaks force-pushed the feature/launch-json-working-dir branch from 2ba0df5 to 30b20de Compare August 16, 2024 00:13
@skybaks skybaks force-pushed the feature/launch-json-working-dir branch from 30b20de to 08447b3 Compare September 7, 2024 12:55
@askebm
Copy link
askebm commented Mar 17, 2025

What is the timeline for getting this merged?

@c-falardeau
Copy link

Hello, I have the issue and I wondered the same thing if this PR will be merged soon ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CLI untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The workingDirectory in the launchSettings.json does not work when use dotnet run
4 participants
0