Example #1
0
        XamarinOptions CreateFromArgs(dynamic args)
        {
            var csProj        = getString(args, VSCodeKeys.XamarinOptions.CSProj);
            var configuration = getString(args, VSCodeKeys.XamarinOptions.Configuration);
            var platform      = getString(args, VSCodeKeys.XamarinOptions.Platform);
            var hasComet      = getBool(args, VSCodeKeys.XamarinOptions.HasComet);
            var shouldDebug   = hasComet ?? getBool(args, VSCodeKeys.XamarinOptions.ForceComet);

            var parser = new ProjectParser(csProj);
            var outPut = parser.OutputFolder(configuration, platform);

            var outputfolder = Path.Combine(Path.GetDirectoryName(csProj), outPut);

            var options = new XamarinOptions()
            {
                CSProj                 = csProj,
                Configuration          = configuration,
                Platform               = platform,
                IsComet                = hasComet,
                ProjectType            = parser.GetProjectType(),
                OutputFolder           = outputfolder,
                IsSim                  = getBool(args, VSCodeKeys.XamarinOptions.IsSimulator, true),
                iOSSimulatorDeviceOS   = getString(args, VSCodeKeys.XamarinOptions.iOSSimulatorOS, "12.4"),
                iOSSimulatorDeviceType = getString(args, VSCodeKeys.XamarinOptions.iOSSimulatorDeviceType, "iPhone-XR"),
            };

            return(options);
        }
Example #2
0
        public override async void Launch(Response response, dynamic args)
        {
            _attachMode = false;

            SetExceptionBreakpoints(args.__exceptionOptions);

            //validate argument 'program'
            //TODO: Remove this
            string programPath = getString(args, "program");

            //if (programPath == null) {
            //	SendErrorResponse(response, 3001, "Property 'program' is missing or empty.", null);
            //	return;
            //}
            programPath = ConvertClientPathToDebugger(programPath);
            //if (!File.Exists(programPath) && !Directory.Exists(programPath)) {
            //	SendErrorResponse(response, 3002, "Program '{path}' does not exist.", new { path = programPath });
            //	return;
            //}



            XamarinOptions xamarinOptions = CreateFromArgs(args);

            if (!ValidateArg(response, xamarinOptions.CSProj, VSCodeKeys.XamarinOptions.CSProj))
            {
                return;
            }

            if (!ValidateArg(response, xamarinOptions.Configuration, VSCodeKeys.XamarinOptions.Configuration))
            {
                return;
            }

            if (!ValidateArg(response, xamarinOptions.Platform, VSCodeKeys.XamarinOptions.Platform))
            {
                return;
            }


            int port = Utilities.FindFreePort(10000);

            var       host    = getString(args, "address");
            IPAddress address = string.IsNullOrWhiteSpace(host) ? IPAddress.Loopback :  Utilities.ResolveIPAddress(host);

            if (address == null)
            {
                SendErrorResponse(response, 3013, "Invalid address '{address}'.", new { address = address });
                return;
            }



            Connect(xamarinOptions, address, port);
            await LaunchiOS(xamarinOptions, port);

            SendResponse(response);
        }
Example #3
0
        async Task LaunchiOS(XamarinOptions options, int port)
        {
            var          workingDir = Path.GetDirectoryName(options.CSProj);
            const string sdkRoot    = "-sdkroot /Applications/Xcode.app/Contents/Developer";


            var appPath       = Directory.EnumerateDirectories(options.OutputFolder, "*.app").FirstOrDefault();
            var iOSSdkVersion = options.iOSSimulatorDeviceOS;

            var success = await RunMlaumchComand(MlaunchPath, workingDir,
                                                 sdkRoot,
                                                 $"--launchsim {appPath}",
                                                 $"--argument=-monodevelop-port --argument={port} --setenv=__XAMARIN_DEBUG_PORT__={port}",
                                                 $"--sdk {iOSSdkVersion} --device=:v2:runtime=com.apple.CoreSimulator.SimRuntime.iOS-{iOSSdkVersion.Replace(".","-")},devicetype=com.apple.CoreSimulator.SimDeviceType.{options.iOSSimulatorDeviceType}"
                                                 );

            Console.WriteLine(success);
        }
Example #4
0
        private void Connect(XamarinOptions options, IPAddress address, int port)
        {
            IDEManager.Shared.StartMonitoring();
            lock (_lock) {
                _debuggeeKilled = false;

                Mono.Debugging.Soft.SoftDebuggerStartArgs args = null;
                if (options.ProjectType == ProjectType.Android)
                {
                    args = new Mono.Debugging.Soft.SoftDebuggerConnectArgs(options.AppName, address, port)
                    {
                        MaxConnectionAttempts         = MAX_CONNECTION_ATTEMPTS,
                        TimeBetweenConnectionAttempts = CONNECTION_ATTEMPT_INTERVAL,
                    };
                }
                else if (options.ProjectType == ProjectType.iOS)
                {
                    if (options.IsSim)
                    {
                        args = new IPhoneSimulatorDebuggerArgs(options.AppName, new IPhoneTcpCommandConnection(IPAddress.Loopback, port))
                        {
                            MaxConnectionAttempts = 10
                        }
                    }
                    ;
                    else
                    {
                        args = new Mono.Debugging.Soft.SoftDebuggerListenArgs(options.AppName, IPAddress.Loopback, port);
                    }
                }

                Console.WriteLine("Listening for debugger!");
                _session.Run(new Mono.Debugging.Soft.SoftDebuggerStartInfo(args), _debuggerSessionOptions);

                _debuggeeExecuting = true;
            }
        }