public void Start() { try { var iisExpressConfigurationFilePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".config"); IisExpressHelper.GenerateIisExpressConfigurationFile(_args, iisExpressConfigurationFilePath); _process = new Process(); _process.Exited += (s, e) => _completed.SetResult(new object()); _process.EnableRaisingEvents = true; _process.StartInfo = IisExpressHelper.BuildProcessStartInfo(_args, iisExpressConfigurationFilePath); if (_process.Start()) { _role.TraceWriteLine(Identifier, "Website started in new IISExpress process: " + _process.Id); } else { throw new NotSupportedException("James: I've not yet found a scenario where this can happen."); } BeginAsyncInfoLoop(_process); BeginAsyncErrorLoop(_process); } catch (Exception ex) { _role.TraceWriteLine(Identifier, "Could not start IIS process: " + ex.Message); _completed.SetResult(new object()); } _started.SetResult(new object()); }
static WebTest() { var mapper = new AssemblyScanningMappingProvider(); mapper.Scan(typeof(AccountRepository).Assembly); EntityMappingProvider.Provider = mapper; _databaseManager.CreateEmptyDatabase(); _databaseManager.InitSchema(); AppDomain.CurrentDomain.DomainUnload += (o, e) => { _iisExpress?.Stop(); _databaseManager.Dispose(); }; // Disables database migration in codeRR.Server.Web project, should be up-to-date already // SchemaUpdateModule does not handle coderr_ConnectionString environment variable // This should only be run on build server due to changes in web.config if (Environment.GetEnvironmentVariable("TF_BUILD") != null) { DisableDatabaseMigrations(); } var configPath = Path.Combine(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\")), "applicationhost.config"); Console.WriteLine($"Path to IIS Express configuration file '{configPath}'"); _iisExpress = new IisExpressHelper { ConfigPath = configPath, // Pass on connectionstring to codeRR.Server.Web during testing, overriding connectionstring in web.config EnvironmentVariables = new Dictionary <string, string> { { "coderr_ConnectionString", _databaseManager.ConnectionString } } }; _iisExpress.Start("codeRR.Server.Web"); // Warmup request only on build server if (Environment.GetEnvironmentVariable("TF_BUILD") != null) { var webClient = new WebClient(); webClient.DownloadString(_iisExpress.BaseUrl); } TestUser = new TestUser { Username = "******", Password = "******", Email = "*****@*****.**" }; TestData = new TestDataManager(_databaseManager.OpenConnection) { TestUser = TestUser }; WebDriver = DriverFactory.Create(BrowserType.Chrome); AppDomain.CurrentDomain.DomainUnload += (o, e) => { DisposeWebDriver(); }; }
protected override void OnStartup(StartupEventArgs e) { try { MultiHostConfigurationFilePath = null; if (e.Args.Length != 1) { var d = new OpenFileDialog(); d.Title = "LightBlue MultiHost: please select multi-host configuration file (.json)"; d.Filter = "MultiHost Configuration Files (.json)|*.json"; d.CheckFileExists = true; if (d.ShowDialog().GetValueOrDefault()) { MultiHostConfigurationFilePath = d.FileName; } } else { MultiHostConfigurationFilePath = e.Args.Single(); } if (string.IsNullOrWhiteSpace(MultiHostConfigurationFilePath)) { Configuration = new MultiHostConfiguration { Roles = new[] { new RoleConfiguration { Title = "Demo Web Site", RoleName = "WebRole" }, new RoleConfiguration { Title = "Demo Web Site 2", RoleName = "WebRole", RoleIsolationMode = "AppDomain" }, new RoleConfiguration { Title = "Demo Domain", RoleName = "CommandProcessor" }, new RoleConfiguration { Title = "Demo Domain 2", RoleName = "ReadModelPopulator", RoleIsolationMode = "AppDomain" } }, }; } else { var configDir = Path.GetDirectoryName(MultiHostConfigurationFilePath); var json = File.ReadAllText(MultiHostConfigurationFilePath); Configuration = JsonConvert.DeserializeObject <MultiHostConfiguration>(json); foreach (var c in Configuration.Roles) { c.ConfigurationPath = Path.GetFullPath(Path.Combine(configDir, c.ConfigurationPath)); c.Assembly = Path.GetFullPath(Path.Combine(configDir, c.Assembly)); } var query = from c in Configuration.Roles let relativePath = c.Assembly.ToLowerInvariant().EndsWith(".dll") || c.Assembly.ToLowerInvariant().EndsWith(".exe") ? Path.GetDirectoryName(c.Assembly) : c.Assembly select relativePath; var assemblyLocations = query.ToArray(); ThreadRunnerAssemblyCache.Initialise(assemblyLocations); IisExpressHelper.KillIisExpressProcesses(); LightBlueConfiguration.SetAsMultiHost(); } base.OnStartup(e); } catch (Exception ex) { MessageBox.Show("Could not start multi-host: " + ex.ToTraceMessage()); } }