0

Environment variables are retrieved via System.Environment.GetEnvironmentVariable("VAR_NAME")

Using export VAR_NAME=123 in bash doesn't work (above command returns null). Setting System.EnvironmentVariableTarget to either User, Machine or Process doesn't work.

Putting a shell script in /etc/profile.d/settings.sh with export VAR_NAME=123 requires a restart which is unacceptable. I haven't been able to find a way to load changes either without restarting. Using source /etc/profile.d/settings.sh doesn't work. I also haven't tested if it actually works after a restart, because I'm not going to restart :)

Exporting the variable through MonoDevelop works, but is not an option since the settings are used across projects. I can't set environment variables for the solution.

There must be better ways. Any clues?

Edit1: Got it working when running the application inside bash. Now I can't debug anything in MonoDevelop, so I'd like to find a way for MonoDevelop to include the required variables without setting them in every project.

Edit2: Got pretty close in MonoDevelop by going to Run -> Run With -> Custom Parameters and adding the environment variables. They're still not applied when debugging though.

Edit3: Using Run With -> Custom Parameters was a dead end as it doesn't support running multiple projects within MonoDevelop. It simply won't allow adding any custom parameters if there's more than one startup project.

2
  • Maybe create a .sh script which exports the variables and runs the mono executable?
    – Gusman
    Apr 28, 2016 at 17:08
  • I wanted to be able to use debugging in MonoDevelop. See my answer below.
    – Jan Sommer
    Apr 28, 2016 at 17:09

1 Answer 1

0

Execute MonoDevelop from bash. This way environment variables are available when debugging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.