Sto provando a scrivere un codice C# per avviare un browser utilizzando Process.Start(app,args);
dove app è il percorso del browser, ad es. /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
e args sono --no-default-browser-check
Come utilizzare Process.Start() o equivalente con Mono su Mac e passare argomenti
se lo faccio, che funziona su Windows e su Linux
Process.Start("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","--no-first-run");
ottengo
open: unrecognized option `--no-first-run'
Usage: open [-e] [-t] [-f] [-W] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames]
Help: Open opens files from a shell.
By default, opens each file using the default application for that file.
If the file is in the form of a URL, the file will be opened as a URL.
Options:
-a Opens with the specified application.
-b Opens with the specified application bundle identifier.
-e Opens with TextEdit.
-t Opens with default text editor.
-f Reads input from standard input and opens with TextEdit.
-W, --wait-apps Blocks until the used applications are closed (even if they were already running).
-n, --new Open a new instance of the application even if one is already running.
-g, --background Does not bring the application to the foreground.
-h, --header Searches header file locations for headers matching the given filenames, and opens them.
Ho anche cercato Monobjc provare eseguire il codice con
// spin up the objective-c runtime
ObjectiveCRuntime.LoadFramework("Cocoa");
ObjectiveCRuntime.Initialize();
NSAutoreleasePool pool = new NSAutoreleasePool();
// Create our process
NSTask task = new NSTask();
NSPipe standardOut = new NSPipe();
task.StandardOutput = standardOut;
task.LaunchPath = @"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
// add some arguments
NSString argumentString = new NSString("--no-first-run");
NSArray arguments = NSArray.ArrayWithObject(argumentString);
task.Arguments = arguments;
// We should have liftoff
task.Launch();
// Parse the output and display it to the console
NSData output = standardOut.FileHandleForReading.ReadDataToEndOfFile;
NSString outString = new NSString(output,NSStringEncoding.NSUTF8StringEncoding);
Console.WriteLine(outString);
// Dipose our objects, gotta love reference counting
pool.Release();
Ma quando eseguo il mio codice utilizzando NUnit fa esplodere NUnit.
Ho il sospetto che si tratti di un errore ma non posso provarlo. Apprezzo qualsiasi aiuto!
Vuol correre che comando funziona una riga di comando? – nos
Sì, funziona. Da quello che posso vedere Process.Start() dovrebbe usare exec per eseguire l'app piuttosto che aprire – AutomatedTester
Che ne dici di creare uno script che esegua Chrome con la riga di comando desiderata ed eseguirlo tramite Mono? – unknownuser