Exemple #1
0
        public static void Main(string[] args)
        {
            BenchmarksEventSource.MeasureAspNetVersion();
            BenchmarksEventSource.MeasureNetCoreAppVersion();

            CreateHostBuilder(args).Build().Run();
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            Console.WriteLine($"Process ID: {Process.GetCurrentProcess().Id}");

            BenchmarksEventSource.MeasureAspNetVersion();
            BenchmarksEventSource.MeasureNetCoreAppVersion();

            var config = new ConfigurationBuilder()
                         .AddEnvironmentVariables(prefix: "ASPNETCORE_")
                         .AddCommandLine(args)
                         .Build();

            var host = new WebHostBuilder()
                       .UseConfiguration(config)
                       .ConfigureLogging(loggerFactory =>
            {
                if (Enum.TryParse(config["LogLevel"], out LogLevel logLevel))
                {
                    loggerFactory.AddConsole().SetMinimumLevel(logLevel);
                }
            })
                       .UseKestrel()
                       .UseStartup <Startup>();

            host.Build().Run();
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                         .AddEnvironmentVariables(prefix: "ASPNETCORE_")
                         .AddCommandLine(args)
                         .Build();

            // The url all requests will be forwarded to
            var baseUriArg = config["baseUri"];

            if (String.IsNullOrWhiteSpace(baseUriArg))
            {
                throw new ArgumentException("--baseUri is required");
            }

            var baseUri = new Uri(baseUriArg);

            // Cache base URI values
            _scheme      = baseUri.Scheme;
            _host        = new HostString(baseUri.Authority);
            _pathBase    = baseUri.AbsolutePath;
            _appendQuery = new QueryString(baseUri.Query);

            Console.WriteLine($"Base URI: {baseUriArg}");

            BenchmarksEventSource.MeasureAspNetVersion();
            BenchmarksEventSource.MeasureNetCoreAppVersion();

            var builder = new WebHostBuilder()
                          .ConfigureLogging(loggerFactory =>
            {
                // Don't enable console logging if no specific level is defined (perf)

                if (Enum.TryParse(config["LogLevel"], out LogLevel logLevel))
                {
                    Console.WriteLine($"Console Logging enabled with level '{logLevel}'");
                    loggerFactory.AddConsole().SetMinimumLevel(logLevel);
                }
            })
                          .UseKestrel((context, kestrelOptions) =>
            {
                kestrelOptions.ConfigureHttpsDefaults(httpsOptions =>
                {
                    httpsOptions.ServerCertificate = new X509Certificate2(Path.Combine(context.HostingEnvironment.ContentRootPath, "testCert.pfx"), "testPassword");
                });
            })
                          .UseContentRoot(Directory.GetCurrentDirectory())
                          .UseConfiguration(config)
            ;

            InitializeHttpClient();

            builder = builder.Configure(app => app.Run(ProxyRequest));


            builder
            .Build()
            .Run();
        }
Exemple #4
0
        public void Configure(IApplicationBuilder app)
        {
            BenchmarksEventSource.MeasureAspNetVersion();
            BenchmarksEventSource.MeasureNetCoreAppVersion();

            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapReverseProxy();
            });
        }
Exemple #5
0
        public void Configure(IApplicationBuilder app)
        {
            BenchmarksEventSource.MeasureAspNetVersion();
            BenchmarksEventSource.MeasureNetCoreAppVersion();

            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapReverseProxy(builder =>
                {
                    // Skip SessionAffinity, LoadBalancing and PassiveHealthChecks
                });
            });
        }
Exemple #6
0
        static Task <int> Main(string[] args)
        {
            var rootCommand = new RootCommand
            {
                new Option <string>(new[] { "--scenario", "-s" }, "Scenario"),
                new Option <bool>(new[] { "--verbose", "-v" }, "Verbose msbuild logs"),
                new Option <bool>("--performanceSummary", "Display MSBuild performance summary."),
            };

            Console.WriteLine(string.Join(" ", args));

            rootCommand.Handler = CommandHandler.Create(async(string scenario, bool verbose, bool performanceSummary) =>
            {
                var workingDirectory = Path.Combine(Directory.GetCurrentDirectory(), Path.GetRandomFileName());
                Directory.CreateDirectory(workingDirectory);
                Console.WriteLine($"Running scenario {scenario}");

                BenchmarksEventSource.MeasureNetCoreAppVersion();

                var dotnet = DotNet.Initialize(workingDirectory, verbose, performanceSummary);

                switch (scenario)
                {
                case "blazorserver":
                    await new BlazorServerScenario(dotnet).RunAsync();
                    break;

                case "blazorwasm":
                    await new BlazorWasmStandaloneScenario(dotnet).RunAsync();
                    break;

                case "blazorwasm-hosted":
                    await new BlazorWasmHosted(dotnet).RunAsync();
                    break;

                case "mvc":
                    await new MvcScenario(dotnet).RunAsync();
                    break;

                case "api":
                    await new ApiScenario(dotnet).RunAsync();
                    break;

                default:
                    throw new InvalidOperationException($"Unknown scenario {scenario}.");
                }
            });

            return(rootCommand.InvokeAsync(args));
        }
Exemple #7
0
 public void Configure(IApplicationBuilder app)
 {
     BenchmarksEventSource.MeasureNetCoreAppVersion();
     BenchmarksEventSource.MeasureAspNetVersion();
 }