示例#1
0
 public DebugSession(DebugClient debugClient, ApplicationType type, WebsiteParameters par, Socket socket)
 {
     Client             = debugClient;
     this.type          = type;
     this.WebParameters = par;
     communication      = new TcpCommunication(socket);
 }
示例#2
0
 public DebugClient(ApplicationType type, string targetExe, WebsiteParameters par, string outputDirectory)
 {
     _type           = type;
     TargetExe       = targetExe;
     WebParameters   = par;
     OutputDirectory = outputDirectory;
 }
示例#3
0
        private void StartMono(ApplicationType type, WebsiteParameters par)
        {
            MonoProcess proc = MonoProcess.Start(type, targetExe, par);

            proc.ProcessStarted          += MonoProcessStarted;
            this.proc                     = proc.Start(directoryName);
            this.proc.EnableRaisingEvents = true;
            this.proc.Exited             += _proc_Exited;
        }
示例#4
0
 public MonoWebProcess(WebsiteParameters par) : this()
 {
     Runtime = par.Runtime;
     if (!string.IsNullOrEmpty(par.Url))
     {
         var url = new Uri(par.Url);
         Port  = url.Port;
         Path  = url.AbsolutePath;
         Https = string.Compare(url.Scheme, "https", true) == 0;
     }
 }
示例#5
0
        internal static MonoProcess Start(ApplicationType type, string _targetExe, WebsiteParameters par)
        {
            if (type == ApplicationType.Desktopapplication)
            {
                return(new MonoDesktopProcess(_targetExe));
            }
            if (type == ApplicationType.Webapplication)
            {
                return(new MonoWebProcess(par));
            }

            throw new Exception("Unknown ApplicationType");
        }
        private Website GetWebsiteIfExists()
        {
            WebsiteParameters websiteParameters = null;

            if (WebsiteProperties != null)
            {
                websiteParameters = WebsiteProperties.WebsiteParameters;
            }

            Name = Name ?? WebsiteProperties.Name;
            if (Name == null)
            {
                throw new FluentManagementException("No name defined for website", "WebsiteClient");
            }
            // get the list of all sites
            var siteList = List();
            // search for the name of the site in the list
            var site = siteList.FirstOrDefault(a => a.Name.ToLowerInvariant() == Name.ToLowerInvariant());

            // make sure that the site exists
            if (site == null)
            {
                throw new FluentManagementException("No site found in this subscription with the name" + Name, "WebsiteClient");
            }
            // get the website configuration
            var command = new GetWebsiteConfigCommand(site)
            {
                SubscriptionId = SubscriptionId,
                Certificate    = ManagementCertificate
            };

            command.Execute();
            site.Config            = command.Config;
            site.WebsiteParameters = site.WebsiteParameters ?? websiteParameters;
            return(WebsiteProperties = site);
        }
示例#7
0
        internal async Task AttachDebugger(string ipAddress)
        {
            string path            = GetStartupAssemblyPath();
            string targetExe       = Path.GetFileName(path);
            string outputDirectory = Path.GetDirectoryName(path);

            Project startup = GetStartupProject();

            bool isWeb = ((object[])startup.ExtenderNames).Any(x => x.ToString() == "WebApplication") ||
                         startup.Properties.OfType <Property>().Any(p => p.Name.StartsWith("WebApplication.") || p.Name.StartsWith("WebSite."));
            ApplicationType   appType = isWeb ? ApplicationType.Webapplication : ApplicationType.Desktopapplication;
            WebsiteParameters webPar  = null;

            if (appType != ApplicationType.Desktopapplication)
            {
                outputDirectory += @"\..\";
                var extUrlProp       = startup.Properties.OfType <Property>().FirstOrDefault(p => p.Name == "WebApplication.StartExternalUrl");
                var frameworkVerProp = startup.Properties.OfType <Property>().FirstOrDefault(prop => prop.Name == "TargetFrameworkVersion");

                var extUrl       = extUrlProp?.Value as string;
                var frameworkVer = ((frameworkVerProp?.Value as string) ?? "v4.0").Substring(1);

                webPar = new WebsiteParameters()
                {
                    Runtime = new Version(frameworkVer) >= new Version(4, 0) ? Runtimes.Net4 : Runtimes.Net2,
                    Url     = extUrl
                };
            }

            var          client  = new DebugClient(appType, targetExe, webPar, outputDirectory);
            DebugSession session = await client.ConnectToServerAsync(ipAddress);

            await session.TransferFilesAsync();

            await session.WaitForAnswerAsync();

            IntPtr pInfo = GetDebugInfo(ipAddress, targetExe, outputDirectory);
            var    sp    = new ServiceProvider((IServiceProvider)_dte);

            try {
                var dbg = (IVsDebugger)sp.GetService(typeof(SVsShellDebugger));
                int hr  = dbg.LaunchDebugTargets(1, pInfo);
                Marshal.ThrowExceptionForHR(hr);

                DebuggedMonoProcess.Instance.AssociateDebugSession(session);
            } catch (Exception ex) {
                logger.Error(ex);
                string msg;
                var    sh = (IVsUIShell)sp.GetService(typeof(SVsUIShell));
                sh.GetErrorInfo(out msg);

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    logger.Error(msg);
                }
                throw;
            } finally {
                if (pInfo != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pInfo);
                }
            }
        }