diff --git a/.vscode/launch.json b/.vscode/launch.json index 617e9d71..91edefa2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,7 +6,7 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/src/TodoApp/bin/Debug/net9.0/TodoApp.dll", + "program": "${workspaceFolder}/src/TodoApp/bin/Debug/net10.0/TodoApp.dll", "args": [], "cwd": "${workspaceFolder}/src/TodoApp", "stopAtEntry": false, diff --git a/.vsconfig b/.vsconfig index 694c29fc..f02c6319 100644 --- a/.vsconfig +++ b/.vsconfig @@ -3,7 +3,7 @@ "components": [ "Microsoft.VisualStudio.Component.CoreEditor", "Microsoft.VisualStudio.Workload.CoreEditor", - "Microsoft.NetCore.Component.Runtime.9.0", + "Microsoft.NetCore.Component.Runtime.10.0", "Microsoft.NetCore.Component.SDK", "Microsoft.VisualStudio.Component.Roslyn.Compiler", "Microsoft.VisualStudio.Component.Roslyn.LanguageServices", diff --git a/NuGet.config b/NuGet.config index 38ac8e75..f326f0cd 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,9 +2,13 @@ + + + + diff --git a/global.json b/global.json index d5209a8f..93aa8f40 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.304", + "version": "10.0.100-preview.7.25380.108", "allowPrerelease": false, "rollForward": "latestMajor", "paths": [ ".dotnet", "$host$" ], diff --git a/src/TodoApp/TodoApp.csproj b/src/TodoApp/TodoApp.csproj index 4aceabb1..fb6c2e88 100644 --- a/src/TodoApp/TodoApp.csproj +++ b/src/TodoApp/TodoApp.csproj @@ -4,15 +4,15 @@ false $(NoWarn);CA1050 TodoApp - net9.0 + net10.0 true latest TodoApp - - - + + + diff --git a/startvscode.cmd b/startvscode.cmd index d321aa83..91142b50 100644 --- a/startvscode.cmd +++ b/startvscode.cmd @@ -11,7 +11,7 @@ SET DOTNET_ROOT(x86)=%~dp0.dotnet\x86 SET PATH=%DOTNET_ROOT%;%PATH% :: Sets the Target Framework for Visual Studio Code. -SET TARGET=net9.0 +SET TARGET=net10.0 SET FOLDER=%~1 diff --git a/tests/TodoApp.Tests/BrowserStackLocalService.cs b/tests/TodoApp.Tests/BrowserStackLocalService.cs index 583a9adf..55c2f4ff 100644 --- a/tests/TodoApp.Tests/BrowserStackLocalService.cs +++ b/tests/TodoApp.Tests/BrowserStackLocalService.cs @@ -197,7 +197,7 @@ private static async Task EnsureBinaryAsync(CancellationToken cancellati Directory.CreateDirectory(localCachePath); - ZipFile.ExtractToDirectory(source, localCachePath); + await ZipFile.ExtractToDirectoryAsync(source, localCachePath, cancellationToken); await File.WriteAllTextAsync(cachedETagFileName, currentETag, Encoding.UTF8, cancellationToken); } diff --git a/tests/TodoApp.Tests/HttpServerFixture.cs b/tests/TodoApp.Tests/HttpServerFixture.cs index 7abb6f41..6ff49e7b 100644 --- a/tests/TodoApp.Tests/HttpServerFixture.cs +++ b/tests/TodoApp.Tests/HttpServerFixture.cs @@ -1,113 +1,34 @@ // Copyright (c) Martin Costello, 2021. All rights reserved. // Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. +using System.Net; using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Hosting.Server; -using Microsoft.AspNetCore.Hosting.Server.Features; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; namespace TodoApp; /// -/// A test server fixture that hosts the application on an HTTP port so +/// A test server fixture that hosts the application on an HTTPS port so /// that the application can be accessed through a browser for UI tests. /// public sealed class HttpServerFixture : TodoAppFixture { - private bool _disposed; - private IHost? _host; - - public string ServerAddress + public HttpServerFixture() { - get - { - EnsureServer(); - return ClientOptions.BaseAddress.ToString(); - } + // Configure the address for the server to listen on for HTTPS + // requests on a dynamic port. with a self-signed TLS certificate. + UseKestrel( + (server) => server.Listen( + IPAddress.Loopback, 0, (listener) => listener.UseHttps( + (https) => https.ServerCertificate = X509CertificateLoader.LoadPkcs12FromFile("localhost-dev.pfx", "Pa55w0rd!")))); } - public override IServiceProvider Services + public string ServerAddress { get { - EnsureServer(); - return _host!.Services!; - } - } - - protected override void ConfigureWebHost(IWebHostBuilder builder) - { - base.ConfigureWebHost(builder); - - // Configure a self-signed TLS certificate for HTTPS - builder.ConfigureKestrel( - serverOptions => serverOptions.ConfigureHttpsDefaults( - httpsOptions => httpsOptions.ServerCertificate = X509CertificateLoader.LoadPkcs12FromFile("localhost-dev.pfx", "Pa55w0rd!"))); - - // Configure the server address for the server to - // listen on for HTTPS requests on a dynamic port. - builder.UseUrls("https://127.0.0.1:0"); - } - - protected override IHost CreateHost(IHostBuilder builder) - { - // Create the host for TestServer now before we - // modify the builder to use Kestrel instead. - var testHost = builder.Build(); - - // Modify the host builder to use Kestrel instead - // of TestServer so we can listen on a real address. - builder.ConfigureWebHost(webHostBuilder => webHostBuilder.UseKestrel()); - - // Create and start the Kestrel server before the test server, - // otherwise due to the way the deferred host builder works - // for minimal hosting, the server will not get "initialized - // enough" for the address it is listening on to be available. - // See https://github.com/dotnet/aspnetcore/issues/33846. - _host = builder.Build(); - _host.Start(); - - // Extract the selected dynamic port out of the Kestrel server - // and assign it onto the client options for convenience so it - // "just works" as otherwise it'll be the default http://localhost - // URL, which won't route to the Kestrel-hosted HTTP server. - var server = _host.Services.GetRequiredService(); - var addresses = server.Features.Get(); - - ClientOptions.BaseAddress = addresses!.Addresses - .Select(x => new Uri(x)) - .Last(); - - // Return the host that uses TestServer, rather than the real one. - // Otherwise the internals will complain about the host's server - // not being an instance of the concrete type TestServer. - // See https://github.com/dotnet/aspnetcore/pull/34702. - return testHost; - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - if (!_disposed) - { - if (disposing) - { - _host?.Dispose(); - } - - _disposed = true; - } - } - - private void EnsureServer() - { - if (_host is null) - { - // This forces WebApplicationFactory to bootstrap the server - using var _ = CreateDefaultClient(); + StartServer(); + return ClientOptions.BaseAddress.ToString(); } } } diff --git a/tests/TodoApp.Tests/TodoApp.Tests.csproj b/tests/TodoApp.Tests/TodoApp.Tests.csproj index b96b56ec..893eb5f7 100644 --- a/tests/TodoApp.Tests/TodoApp.Tests.csproj +++ b/tests/TodoApp.Tests/TodoApp.Tests.csproj @@ -4,7 +4,7 @@ $(NoWarn);CA1861 Exe TodoApp - net9.0 + net10.0 @@ -13,7 +13,7 @@ - +