❔ Can't change environment variables in Rider
When I click on Edit Configurations and select a configuration to edit, the environment variables are read only. This config is based on a 'launchSettings.json' so there is a notice in the config editor that "profile parameters are set by launchSettings", and some fields are greyed out because of that, but not Environment variables. That field appears to be editable but is not.
Looking around I found one StackOverflow accepted answer that says one should edit the environment variables in launchSettings.json, but in my run/debug config, there is one variable that isn't in launchSettings.json. Note in the images that 'ASPNETCORE_URLS' is not present in launchSettings.
I am trying to get rid of that variable because I suspect it is causing an exception to be thrown when I try and debug the app. It doesn't throw an exception in VS and the only difference I can see is that the VS launch profile doesn't have the ASPNETCORE_URLS variable.
6 Replies
ASPNETCORE_URLS should come from applicationUrl in the launchSettings. If you want to have full control of the run profile in Rider, you can add a new profile of the type ‘.NET Project’ and manually configure all environment variables.
Thank you, TIL something about Rider configs. Creating a new config without without ASPNETCORE_URLS didn't help: In Rider I still get the error
Invalid URI: The URI is empty
and a UrlFormatException
. I suspect t's my REMOTE_CONFIGURATION_LOCATION
variable which is empty. Yet it's supposed to be empty, and in VS it runs fine without that exception being raised. It seems to run fine in Rider if I just totally remove REMOTE_CONFIGURATION_LOCATION
, but I wonder why it throws in Rider and not VS.Have you tried running it with a debugger attached in Rider and having 'break on any exceptions' and maybe 'debug external code' enabled to see where it fails?
I have now that you remind me, I originally gave up on that because the exception is thrown in external code and Rider doesn't seem to want to break on exceptions there. But I found I could step into it, and I see it tries to call
new Uri
with an empty string. It is the string from the REMOTE_CONFIGURATION_LOCATION
environment variable.
When I tried to step into the code in VS it didn't want to step into that external code, but now that I have tried again and used the External Sources node in Solution Explorer I see that VS interprets an empty string for an environment variable as null where Rider correctly sees it as an empty string.
Thanks, but now I'm stuck again with how to work around this in Rider. If I say use a space for the environment variable value, then I still get a UriFormatException, and if I use a valid Url it either fails to load the remote configuration or at best loads the wrong config.What if you remove that variable from the list of environment variables? It should end up as null when you run the application.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.