Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
It appears that Directory.GetCurrentDirectory() is always "/" for MonoMac applications. This means handling relative arguments from command line very difficult.
I would guess that's the actual working directory that launch services starts the app with.
How are you passing the commandline args to the app?
MyApp.app/Contents/MacOS/MyApp.AutomatedTest -c=Param1 -t=Param2
Is there a better way to launch the app? "open MyApp.app" doesn't redirect stdout to the terminal.
Hm, if you're opening the app by invoking its executable directly then I would expect the working directory to be your current location unless AppKit is changing it during NSApplication.Init() maybe?
Nope, you won't get stdout if you use open. OTOH, if you run the exe directly, a few things won't behave exactly like they do when opened with launch services, so you may want to add logging to your app.
When running Monomac apps from MD, we run them with Launch Services, but set a special MONOMAC_LOGDIR environment variable that causes the MonoMac entry point to redirect stderr/stdout to log files before hitting Main.
getcwd() and Directory.GetCurrentDirectory() both agree. This is just how the mac launcher works. :(