private void ValidateCode() { ClearErrors(); int ce = Code; if ((ce == null)) { AddError("Code", Properties.Resources.Error_Required); } else if ((XCode.Contains(ce))) { AddError("Code", Properties.Resources.Error_CodeAlreadyExist); } else { if (fcode != Code) { MessageBoxResult result = MessageBox.Show("Voulez vous changer le code du cours ?", "Confirmation", MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: Course.Code = (int)code; App.CurrentCourse = Course; break; case MessageBoxResult.No: break; } } } RaiseErrors(); }
async Task <(bool success, string message)> LaunchiOS(Response response, LaunchData launchOptions, int port) { //var ipstr = string.Join(";", GetLocalIps()); //Environment.SetEnvironmentVariable("__XAMARIN_DEBUG_HOSTS__", ipstr); //Environment.SetEnvironmentVariable("__XAMARIN_DEBUG_PORT__", port.ToString()); //var args = new string[] //{ // "build", // "--no-restore", // "-f", // launchOptions.ProjectTargetFramework, // $"\"{launchOptions.Project}\"", // "-t:Run", // $"-p:_DeviceName=\":v2:udid={launchOptions.iOSSimulatorDeviceUdid}\"", // $"-p:MtouchExtraArgs=\"-v -v -v -v --setenv:__XAMARIN_DEBUG_PORT__={port} --setenv:__XAMARIN_DEBUG_HOSTS__={ipstr}\"", // "-verbosity:diag", // "-bl:/Users/redth/Desktop/iosdbg.binlog" //}; //SendConsoleEvent("Executing: dotnet " + string.Join(" ", args)); //return await Task.Run(() => DotNet.Run( // d => SendConsoleEvent(d), // args)); var workingDir = Path.GetDirectoryName(launchOptions.Project); var xcodePath = Path.Combine(XCode.GetBestXcode(), "Contents", "Developer"); string sdkRoot = $"-sdkroot {xcodePath}"; SendConsoleEvent($"Using `{sdkRoot}`"); string appPath = default; DateTime appPathLastWrite = DateTime.MinValue; var output = Path.Combine( workingDir, "bin", launchOptions.Configuration, launchOptions.ProjectTargetFramework); if (Directory.Exists(output)) { var ridDirs = Directory.GetDirectories(output) ?? new string[0]; foreach (var ridDir in ridDirs) { // Find the newest .app generated and assume that's the one we want var appDirs = Directory.EnumerateDirectories(ridDir, "*.app", SearchOption.AllDirectories); foreach (var appDir in appDirs) { var appDirTime = Directory.GetLastWriteTime(appDir); if (appDirTime > appPathLastWrite) { appPath = appDir; appPathLastWrite = appDirTime; } } } } if (string.IsNullOrEmpty(appPath)) { var msg = $"No .app found in folder: {output}"; SendConsoleEvent(msg); SendErrorResponse(response, 3002, msg); return(false, ""); } SendConsoleEvent($"Found .app: {appPath}"); var dotnetSdkDir = Microsoft.DotNet.NativeWrapper.EnvironmentProvider.GetDotnetExeDirectory(); var mlaunchPath = string.Empty; var dotnetSkdPath = Path.Combine(dotnetSdkDir, "packs", "Microsoft.iOS.Sdk"); // 14.4.100-ci.main.1192/tools/bin/mlaunch if (!Directory.Exists(dotnetSkdPath)) { var msg = dotnetSkdPath + " is missing, please install the iOS SDK Workload"; SendConsoleEvent(msg); SendErrorResponse(response, 3002, msg); return(false, ""); } // TODO: Use WorkloadResolver to get pack info for `Microsoft.iOS.Sdk` to choose // the actual one that's being used - just not sure how to get dotnet sdk version in use SendConsoleEvent($"Looking for Microsoft.iOS.Sdk tools in: {dotnetSkdPath}"); foreach (var dir in Directory.GetDirectories(dotnetSkdPath).Reverse()) { var mlt = Path.Combine(dir, "tools", "bin", "mlaunch"); if (File.Exists(mlt)) { mlaunchPath = mlt; break; } } //mlaunchPath = "/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch"; if (string.IsNullOrEmpty(mlaunchPath) || !File.Exists(mlaunchPath)) { var msg = "Could not locate mlaunch tool in Microsoft.iOS.Sdk workload."; SendConsoleEvent(msg); SendErrorResponse(response, 3002, msg); return(false, msg); } SendConsoleEvent($"Found mlaunch: {mlaunchPath}"); var success = await RunMlaumchComand(mlaunchPath, workingDir, sdkRoot, $"--launchsim \"{appPath}\"", $"--argument=-monodevelop-port --argument={port} --setenv=__XAMARIN_DEBUG_PORT__={port}", $"--device=:v2:udid={launchOptions.DeviceId}" //$"--sdk {launchOptions.iOSSimulatorVersion} --device=:v2:udid={launchOptions.DeviceId}" //$"--sdk {launchOptions.iOSSimulatorVersion} --device=:v2:runtime={launchOptions.iOSSimulatorDevice},devicetype={launchOptions.iOSSimulatorDeviceType}" ); return(success); }