public override bool Execute()
        {
            Log.LogTaskName("CreateDebugConfiguration");
            Log.LogTaskProperty("AppBundleDir", AppBundleDir);
            Log.LogTaskProperty("DebugOverWiFi", DebugOverWiFi);
            Log.LogTaskProperty("DebugIPAddresses", DebugIPAddresses);
            Log.LogTaskProperty("DebuggerPort", DebuggerPort);
            Log.LogTaskProperty("SdkIsSimulator", SdkIsSimulator);

            var ips     = DebugIPAddresses?.Split(new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            var path    = Path.Combine(AppBundleDir, "MonoTouchDebugConfiguration.txt");
            var added   = new HashSet <string> ();
            var builder = new StringBuilder();

            if (ips != null)
            {
                foreach (var ip in ips)
                {
                    if (added.Contains(ip))
                    {
                        continue;
                    }

                    builder.Append("IP: ");
                    builder.AppendLine(ip);
                    added.Add(ip);
                }
            }

            if (!DebugOverWiFi && !SdkIsSimulator)
            {
                builder.AppendLine("USB Debugging: 1");
            }

            builder.Append("Port: ");
            builder.AppendLine(DebuggerPort);

            var text = builder.ToString();

            try {
                if (!File.Exists(path) || File.ReadAllText(path) != text)
                {
                    File.WriteAllText(path, text);
                }
            } catch (Exception ex) {
                Log.LogError(ex.Message);
            }

            return(!Log.HasLoggedErrors);
        }
Пример #2
0
        public override bool Execute()
        {
            var path = Path.Combine(AppBundleDir, "MonoTouchDebugConfiguration.txt");

            Log.LogTaskName("CreateDebugConfiguration");
            Log.LogTaskProperty("AppBundleDir", AppBundleDir);
            Log.LogTaskProperty("DebugOverWiFi", DebugOverWiFi);
            Log.LogTaskProperty("DebugIPAddresses", DebugIPAddresses);
            Log.LogTaskProperty("DebuggerPort", DebuggerPort);
            Log.LogTaskProperty("SdkIsSimulator", SdkIsSimulator);

            var ips = DebugIPAddresses?.Split(new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            try {
                using (var stream = new FileStream(path, FileMode.Create, FileAccess.Write)) {
                    using (var writer = new StreamWriter(stream)) {
                        var added = new HashSet <string> ();
                        if (ips != null)
                        {
                            foreach (var ip in ips)
                            {
                                string str = ip.ToString();

                                if (added.Contains(str))
                                {
                                    continue;
                                }

                                writer.WriteLine("IP: {0}", str);
                                added.Add(str);
                            }
                        }

                        if (!DebugOverWiFi && !SdkIsSimulator)
                        {
                            writer.WriteLine("USB Debugging: 1");
                        }

                        writer.WriteLine("Port: {0}", DebuggerPort);
                    }
                }
            } catch (Exception ex) {
                Log.LogError(ex.Message);
            }

            return(!Log.HasLoggedErrors);
        }