Пример #1
0
    protected override IHost CreateWebHost()
    {
        if (TestTrimmedApps)
        {
            var staticFilePath = Path.Combine(AppContext.BaseDirectory, "trimmed", typeof(TProgram).Assembly.GetName().Name);
            if (!Directory.Exists(staticFilePath))
            {
                throw new DirectoryNotFoundException($"Test is configured to use trimmed outputs, but trimmed outputs were not found in {staticFilePath}.");
            }

            return(CreateStaticWebHost(staticFilePath));
        }

        ContentRoot = FindSampleOrTestSitePath(
            typeof(TProgram).Assembly.FullName);

        var host = "127.0.0.1";

        if (E2ETestOptions.Instance.SauceTest)
        {
            host = E2ETestOptions.Instance.Sauce.HostName;
        }

        var args = new List <string>
        {
            "--urls", $"http://{host}:0",
            "--contentroot", ContentRoot,
            "--pathbase", PathBase,
            "--applicationpath", typeof(TProgram).Assembly.Location,
        };

        if (!string.IsNullOrEmpty(Environment))
        {
            args.Add("--environment");
            args.Add(Environment);
        }

        return(DevHostServerProgram.BuildWebHost(args.ToArray()));
    }
Пример #2
0
 static int Main(string[] args)
 {
     DevServerProgram.BuildWebHost(args).Run();
     return(0);
 }