Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to ASP.NET Core 9 #1017

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/TodoApp/bin/Debug/net8.0/TodoApp.dll",
"program": "${workspaceFolder}/src/TodoApp/bin/Debug/net9.0/TodoApp.dll",
"args": [],
"cwd": "${workspaceFolder}/src/TodoApp",
"stopAtEntry": false,
Expand Down
2 changes: 1 addition & 1 deletion .vsconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"components": [
"Microsoft.VisualStudio.Component.CoreEditor",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.NetCore.Component.Runtime.8.0",
"Microsoft.NetCore.Component.Runtime.9.0",
"Microsoft.NetCore.Component.SDK",
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
"Microsoft.VisualStudio.Component.Roslyn.LanguageServices",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ with [User Secrets] instead.

Compiling the application yourself requires Git and the
[.NET SDK](https://www.microsoft.com/net/download/core "Download the .NET SDK")
to be installed (version `8.0.100` or later).
to be installed (version `9.0.100` or later).

To build and test the application locally from a terminal/command-line, run the
following set of commands:
Expand Down
1 change: 1 addition & 0 deletions TodoApp.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<Rule Id="CA1056" Action="None" />
<Rule Id="CA1062" Action="None" />
<Rule Id="CA1303" Action="None" />
<Rule Id="CA1515" Action="None" />
<Rule Id="CA1707" Action="None" />
<Rule Id="CA1711" Action="None" />
<Rule Id="CA1720" Action="None" />
Expand Down
4 changes: 0 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ param(
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = "true"
$env:NUGET_XMLDOC_MODE = "skip"

if ($null -eq $env:MSBUILDTERMINALLOGGER) {
$env:MSBUILDTERMINALLOGGER = "auto"
}

$Configuration = "Release"
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.403",
"version": "9.0.100-rc.2.24474.11",
"allowPrerelease": false,
"rollForward": "latestMajor"
}
Expand Down
13 changes: 8 additions & 5 deletions src/TodoApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
builder.Services.AddRazorPages();

// Configure OpenAPI documentation for the Todo API
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddOpenApiDocument(options =>
builder.Services.AddOpenApi(options =>
{
options.Title = "Todo API";
options.Version = "v1";
options.AddDocumentTransformer((document, _, _) =>
{
document.Info.Title = "Todo API";
document.Info.Version = "v1";
return Task.CompletedTask;
});

Check warning on line 27 in src/TodoApp/Program.cs

View check run for this annotation

Codecov / codecov/patch

src/TodoApp/Program.cs#L22-L27

Added lines #L22 - L27 were not covered by tests
});

if (string.Equals(builder.Configuration["CODESPACES"], "true", StringComparison.OrdinalIgnoreCase))
Expand Down Expand Up @@ -57,7 +60,7 @@
app.UseAuthorization();

// Add endpoint for OpenAPI
app.UseOpenApi();
app.MapOpenApi();

// Add the HTTP endpoints
app.MapAuthenticationRoutes();
Expand Down
6 changes: 3 additions & 3 deletions src/TodoApp/TodoApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CA1050</NoWarn>
<RootNamespace>TodoApp</RootNamespace>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>latest</TypeScriptToolsVersion>
<UserSecretsId>TodoApp</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspNet.Security.OAuth.GitHub" Version="8.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0-rc.2.24474.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0-rc.2.24474.1" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.6.2" PrivateAssets="all" />
<PackageReference Include="NSwag.AspNetCore" Version="14.1.0" />
</ItemGroup>
<ItemGroup>
<Content Update="package.json;package-lock.json;tsconfig.json" CopyToPublishDirectory="Never" />
Expand Down
2 changes: 1 addition & 1 deletion src/TodoApp/wwwroot/swagger-ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<script>
window.onload = function () {
window.ui = SwaggerUIBundle({
url: "/swagger/v1/swagger.json",
url: "/openapi/v1.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
Expand Down
2 changes: 1 addition & 1 deletion startvscode.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SET DOTNET_ROOT(x86)=%~dp0.dotnetcli\x86
SET PATH=%DOTNET_ROOT%;%PATH%

:: Sets the Target Framework for Visual Studio Code.
SET TARGET=net8.0
SET TARGET=net9.0

SET FOLDER=%~1

Expand Down
2 changes: 1 addition & 1 deletion tests/TodoApp.Tests/HttpServerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
// Configure a self-signed TLS certificate for HTTPS
builder.ConfigureKestrel(
serverOptions => serverOptions.ConfigureHttpsDefaults(
httpsOptions => httpsOptions.ServerCertificate = new X509Certificate2("localhost-dev.pfx", "Pa55w0rd!")));
httpsOptions => httpsOptions.ServerCertificate = X509CertificateLoader.LoadPkcs12FromFile("localhost-dev.pfx", "Pa55w0rd!")));
Dismissed Show dismissed Hide dismissed

// Configure the server address for the server to
// listen on for HTTPS requests on a dynamic port.
Expand Down
5 changes: 3 additions & 2 deletions tests/TodoApp.Tests/TodoApp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CA1861</NoWarn>
<RootNamespace>TodoApp</RootNamespace>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="coverlet.msbuild" Version="6.0.2" PrivateAssets="All" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageReference Include="JustEat.HttpClientInterception" Version="4.3.0" />
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0-rc.2.24474.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Microsoft.Playwright" Version="1.47.0" />
<PackageReference Include="ReportGenerator" Version="5.3.10" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="System.Text.Encodings.Web" Version="9.0.0-rc.2.24473.5" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
Expand Down