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()); } }
private static NuGetStartOptions BuildOptions(string name, IEnumerable <string> urls, IEnumerable <string> services) { var options = new NuGetStartOptions(); foreach (var url in urls) { options.Urls.Add(url); } options.Services = services; options.AppDescription = new ServiceHostDescription( ServiceHostInstanceName.Parse("nuget-local-0-" + name + "_IN0"), Environment.MachineName); return(options); }
private static ServiceHostDescription GetServiceDescription(string hostName) { return(new ServiceHostDescription( ServiceHostInstanceName.Parse("nuget-local-0-" + hostName + "_IN0"), Environment.MachineName)); }