protected override IEnumerable <string> GetHttpUrls()
        {
            var http   = GetEndpoint(Constants.HttpEndpoint);
            var https  = GetEndpoint(Constants.HttpsEndpoint);
            var config = Config.GetSection <HttpConfiguration>();

            return(NuGetApp.GetUrls(
                       http == null ? (int?)null : http.Port,
                       https == null ? (int?)null : https.Port,
                       config.BasePath,
                       localOnly: false));
        }
Beispiel #2
0
        private void LoadAndStartApp(Arguments parsed, NuHostConfig config)
        {
            // Create start options
            NuGetDomainStartOptions options = new NuGetDomainStartOptions()
            {
                HostApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                ApplicationBase     = parsed.BaseDirectory
            };

            if (!String.IsNullOrEmpty(parsed.Configuration))
            {
                options.Configuration = JsonConvert.DeserializeObject <Dictionary <string, string> >(parsed.Configuration);
            }

            options.AppDescription = new ServiceHostDescription(
                ServiceHostInstanceName.Parse("nuget-local-0-nuhost_IN" + Process.GetCurrentProcess().Id.ToString()),
                Environment.MachineName);
            if (parsed.Services != null)
            {
                options.Services = parsed.Services.ToList();
            }
            var urls = parsed.Urls ?? NuGetApp.GetUrls(parsed.HttpPort, parsed.HttpsPort, parsed.HttpPath, localOnly: true);

            foreach (var url in urls)
            {
                options.Urls.Add(url);
            }

            // Create the AppDomain
            var setup = new AppDomainSetup()
            {
                ApplicationBase   = options.ApplicationBase,
                ConfigurationFile = config.ClrConfigFile
            };
            var     domain = AppDomain.CreateDomain("NuGetServices", null, setup);
            dynamic agent  = domain.CreateInstanceAndUnwrap(
                "NuGet.Services.Platform",
                "NuGet.Services.Hosting.ConsoleApplicationHost");

            try
            {
                agent.Run(options);
            }
            catch (AggregateException aex)
            {
                Console.WriteLine(aex.InnerException.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }