I have a .NET library that needs to run under Mono, and in order to work properly I need to determine the path of the Mono installation. Mono docs mention a MONO_HOME environment variable, but after installing Mono for Windows, this variable is not set, so it does not appear to be reliable. Is it reliable on Linux? Do I have any alternative on Windows other than requiring users of my library to manually set MONO_HOME correctly in order for things to work?
I need a way to determine where all of the Mono versions of the framework assemblies are, because my library basically does what Visual Studio does (loads solutions and projects, loads metadata from framework assemblies depending upon the specified target framework version, etc).
This should work on both platforms:
See also the private
GacPathproperty in Environment.cs, that’s how it’s computed on Windows. I also just tried this on my Mac and it’s returning the correct installation directory.