Can't set environment variables for .net launch settings profile


I created a new .net core 2.2 project using the empty template in rider.  What I want to do is ensure the port is the same each time I run.  (For now so I can use the rest client to test it, but later for integration testing.)

I believe the way I'm supposed to fix this is to add an environment variable ASPNETCORE_URLS with the url.

Fine, so I click Edit Configurations, and then press the icon next to Environment Variables.  It pops up and shows me ASPNETCORE_ENVIRONENT set to Development.  But the little toolbar which lets me add environment variables is missing.  After a bit of prodding about, I find the keyboard shortcut and add the new setting in.  But when I close the dialog, the new key disappears.

I'm reasonably sure this configuration was added by Rider when I created the project, or when I chose to run it.

What I noticed is that this configuration is a ".NET Launch Settings Profile" type.  If I create a new configuration using ".NET Project' then the environment variables window works fine.  I'm not sure I know what the difference is.

So maybe this is the answer, but I'm sure this behaviour can't be correct can it??

I'm using 2018.3 with OSX Mojave.

Comment actions Permalink

Ah, 2 minutes after posting this I stumbled on what I think the answer is... there's a launchSettings.json file under Properties that seems to be where I'm supposed to configure this I think.

I've not spent much time with .net core before and must admit, it's all quite confusing.  There seem to be a lot of different ways to configure the same thing.  I've not yet figured out what the differences are.

Comment actions Permalink

Hi John,

Yes, you got it right. Starting from v2018.3 Rider has a new type of run configuration, which is generated from launchSettings.json: That is why some of the fields are not editable from the dialog.

The main difference between ".NET Project" and ".NET Launch Settings Profile" is that the first one is saved in .idea folder (IntelliJ way) and the second one in launchSettings.json (.NET Core way).

Comment actions Permalink

I eventually found out when I actually read the dialog properly!  Before I was just honing in on the environment variables, which is what I thought I wanted, and was then confused when it didn't really work properly.


I wonder if it's worth changing it so that the editor can modify launchsettings.json, or alternatively if the edit button takes you to the json file in the editor.

Comment actions Permalink


Thanks for sharing your thoughts! Please upvote this issue on YouTrack:

Comment actions Permalink

I think this should be changed. Because what if I want to put in something like:

I don't want to check in my certificate password to the source code so now I have to work around this... better in my opinion if you decouple it like how it is in Pycharm.

Comment actions Permalink

Hello AustEcon,

Thanks for your feedback! Could you please describe your case in more details? I'm afraid I don't understand what exactly you'd like to be changed.

Do I understand correctly that you're using `launchsettings.json` file to describe how your project can be launched, and you'd like to store environment variables containing sensitive data in it? As far as I know, they suggest using Secrets Manager for this purpose. Please also see this ticket about Secrets Manager in Rider.

Comment actions Permalink

Hi. My usecase is actually to get ssl certificates and connectivity all working from within docker.

And the usual way that is done is by specifying environment variables in the docker compose for each instance of the dotnet server (rather than say... overwriting the appsettings.json).

The other environment variables that I frequently need to manipulate are:
One that sets the Connection string to database for entity framework.

The IP address needs to be host.docker.internal sometimes and other times localhost... and sometimes I have to shuffle ports about aswell... so env vars are really nice and descriptive in the docker-compose.yaml.

And yes things like passwords are usually done via User Secrets which I am using for docker but when I am just hacking around to get to a solution I don't always want to have to do that.

I understand that I could overwrite the json each time but ASPNETCORE_ prefixed environment variables is quite a common way of changing the configuration (I think on azure etc too)... so in my opinion it would be best if Rider made it easier to change the environment environment variables between runs to test that the configuration code paths are picking up the new settings as the dev intends.


Comment actions Permalink

Hi AustEcon,

Thank you for the detailed explanation. We are now planning to make ".NET Launch Settings Profile" run configuration editable, see RIDER-23217. We haven't decided yet if the UI will allow editing the launchSettings.json itself, or it will allow adding additional environment variables and store it locally. Your feedback will help us to choose. Most likely, Rider will support both cases in the future.

At the moment, the only way is to set environment variables manually right in the launchSettings.json file.

Please let me know if you have any questions.

Please sign in to leave a comment.