Getting different working directories when staring a project.
In Rider I have an existing solution that I added a new project folder to. When I run this new project from the services tab the program.cs Main function shows the current working directory as coming from {root}\ bin\Debug\net6.0. When I run one of the previously existing projects the current working directory is just the {root} folder (which is what I want).
From what I can see both projects are setup the same. I can't find anything that explains the starting working directory difference.
I've looked at service configurations, launchSettings.json, *.csproj , and anything else I could think of. There is a working directory field on the edit configurations but it's empty and not editable.
Please sign in to leave a comment.
thank you for contacting us.
Could you please send us the screenshot of your run configuration that you run?
Thank you!
Sure, where do I send it to?
Hi,
Please attach it here or use the big blue button in the right corner “Submit a request”.
Thank you!
Okay Thank You. I blocked out the proj name. The top image is from the project that starts in \bin\net6.0 and the bottom the one that starts in root.
Launch Settings in same order. I replaced actual project name with {PROJECT NAME}
{"profiles": {"{PROJECT NAME}": {"commandName": "Project","launchUrl": "http://*:44397","applicationUrl": "http://*:44397","environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development"}}}}{"profiles": {"{PROJECT NAME}": {"commandName": "Project","applicationUrl": "http://*:44399","environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development"}}}}Hi Kenneth,
thank you for the answer.
Please also send us a screenshot of RunWorkingDirectory property for project where it works not as you expected.
Thank you!
Sweet I think we are getting somewhere.
The RunWorkingDirectory for the the new project is blank.
The RunWorkingDirectory for the older project is set to the projects root folder.
So how do I edit this property?
Hi,
thank you for the answer.
You could try to write directly in
.csprojfile, like this:<PropertyGroup><!-- … --><RunWorkingDirectory>$(MSBuildThisFileDirectory)</RunWorkingDirectory></PropertyGroup>Thank you!
Okay that worked. Which is Great. So thank You.
I don't see that setting in the .csproj file of the existing project which is working . Would this be set anywhere else?
Hi,
it might be set up in
Directory.Build.props(file located near the solution).Or you can right-click on the project in Rider and run "Advanced Build Actions → Build with Diagnostics", then view it in MSBuild Log Viewer
Thank you!