-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: main
Are you sure you want to change the base?
Conversation
@dotnet-policy-service agree |
@@ -73,6 +73,10 @@ public int Execute() | |||
{ | |||
targetCommand.SetCommandArgs(launchSettings.CommandLineArgs); | |||
} | |||
if (string.IsNullOrEmpty(targetCommand.CommandWorkingDirectory) && launchSettings.WorkingDirectory != null) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
2ba0df5
to
30b20de
Compare
30b20de
to
08447b3
Compare
What is the timeline for getting this merged? |
Hello, I have the issue and I wondered the same thing if this PR will be merged soon ? |
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.