diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f45e2de..04075c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,8 +39,9 @@ jobs: working-directory: ./src # Unfortunately, --no-build does not seem to work when we publish a specific project, so we use --no-restore instead + # Skip adding a web.config for IIS, as we will always use Kestrel (IsTransformWebConfigDisabled=true) - name: Publish - run: dotnet publish FlaUI.WebDriver/FlaUI.WebDriver.csproj --no-restore --configuration $env:Configuration --self-contained + run: dotnet publish FlaUI.WebDriver/FlaUI.WebDriver.csproj --no-restore --configuration $env:Configuration --self-contained /p:IsTransformWebConfigDisabled=true working-directory: ./src - name: Upload build artifacts diff --git a/src/FlaUI.WebDriver.sln b/src/FlaUI.WebDriver.sln index 75dcbf4..9e76c41 100644 --- a/src/FlaUI.WebDriver.sln +++ b/src/FlaUI.WebDriver.sln @@ -13,6 +13,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlaUI.WebDriver.UITests", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfApplication", "TestApplications\WpfApplication\WpfApplication.csproj", "{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4F6F2546-27D9-468C-AD80-1629B54139DA}" + ProjectSection(SolutionItems) = preProject + ..\README.md = ..\README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/src/FlaUI.WebDriver/FlaUI.WebDriver.csproj b/src/FlaUI.WebDriver/FlaUI.WebDriver.csproj index 64eaaf1..ff59d7e 100644 --- a/src/FlaUI.WebDriver/FlaUI.WebDriver.csproj +++ b/src/FlaUI.WebDriver/FlaUI.WebDriver.csproj @@ -3,7 +3,7 @@ net6.0-windows enable - disable + enable preview false win-x64 @@ -11,13 +11,13 @@ true - - FlaUI.WebDriver.Program - - + + + + diff --git a/src/FlaUI.WebDriver/Program.cs b/src/FlaUI.WebDriver/Program.cs index a490bb4..4ef1cd6 100644 --- a/src/FlaUI.WebDriver/Program.cs +++ b/src/FlaUI.WebDriver/Program.cs @@ -1,22 +1,31 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; -using System.IO; -using System.Reflection; +using FlaUI.WebDriver; +using Microsoft.OpenApi.Models; -namespace FlaUI.WebDriver +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddSingleton(); + +builder.Services.Configure(options => options.LowercaseUrls = true); +builder.Services.AddControllers(options => + options.Filters.Add(new WebDriverResponseExceptionFilter())); + +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(c => { - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } + c.SwaggerDoc("v1", new OpenApiInfo { Title = "FlaUI.WebDriver", Version = "v1" }); +}); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "FlaUI.WebDriver v1")); } + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/src/FlaUI.WebDriver/Startup.cs b/src/FlaUI.WebDriver/Startup.cs deleted file mode 100644 index 4262641..0000000 --- a/src/FlaUI.WebDriver/Startup.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.OpenApi.Models; -using System; - -namespace FlaUI.WebDriver -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - services.AddSingleton(); - - services.Configure(options => options.LowercaseUrls = true); - services.AddControllers(options => - options.Filters.Add(new WebDriverResponseExceptionFilter())); - services.AddSwaggerGen(c => - { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "FlaUI.WebDriver", Version = "v1" }); - }); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseSwagger(); - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "FlaUI.WebDriver v1")); - } - - app.Use(async (context, next) => - { - context.Response.GetTypedHeaders().CacheControl = - new Microsoft.Net.Http.Headers.CacheControlHeaderValue() - { - NoCache = true, - }; - await next(); - }); - - app.UseRouting(); - - app.UseAuthorization(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -}