From 21f33a2062d20b8d3f71456aeeee87192ee32e07 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 27 Aug 2026 14:59:34 +0000 Subject: [PATCH] Upgrade solution to .NET 9 Co-Authored-By: harrison.reeves --- .github/workflows/dotnet.yml | 6 +++--- Dockerfile | 4 ++-- README.md | 2 +- global.json | 6 ++++++ src/Application/Application.csproj | 4 ++-- src/Domain/Domain.csproj | 2 +- src/Infrastructure/Infrastructure.csproj | 16 ++++++++-------- src/WebApi/Program.cs | 6 ++++-- src/WebApi/WebApi.csproj | 10 +++++----- tests/Application.Tests/Application.Tests.csproj | 12 ++++++------ tests/WebApi.Tests/WebApi.Tests.csproj | 12 ++++++------ 11 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 global.json diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 25f43e7..7fcd6dc 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -15,11 +15,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.x + dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/Dockerfile b/Dockerfile index 20b2ef6..b977745 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base WORKDIR /app EXPOSE 5000 -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build RUN pwd && ls / WORKDIR /src COPY ["src/WebApi/WebApi.csproj", "src/WebApi/"] diff --git a/README.md b/README.md index aef0094..ace68d0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## ASP.NETCore Web API Sample -This repository is a sample ASP.NET Core Web API (.NET 7) project. +This repository is a sample ASP.NET Core Web API (.NET 9) project. ## Features & Technologies - ASP.NET Core Web API diff --git a/global.json b/global.json new file mode 100644 index 0000000..114bdb3 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "9.0.317", + "rollForward": "latestFeature" + } +} diff --git a/src/Application/Application.csproj b/src/Application/Application.csproj index f445bb6..6deccd8 100644 --- a/src/Application/Application.csproj +++ b/src/Application/Application.csproj @@ -1,13 +1,13 @@  - net7.0 + net9.0 enable enable - + diff --git a/src/Domain/Domain.csproj b/src/Domain/Domain.csproj index a1ed5b3..125f4c9 100644 --- a/src/Domain/Domain.csproj +++ b/src/Domain/Domain.csproj @@ -1,7 +1,7 @@  - net7.0 + net9.0 enable enable diff --git a/src/Infrastructure/Infrastructure.csproj b/src/Infrastructure/Infrastructure.csproj index 64bf71d..a780746 100644 --- a/src/Infrastructure/Infrastructure.csproj +++ b/src/Infrastructure/Infrastructure.csproj @@ -1,25 +1,25 @@  - net7.0 + net9.0 enable enable - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + diff --git a/src/WebApi/Program.cs b/src/WebApi/Program.cs index 41c43e7..3e1bbf3 100644 --- a/src/WebApi/Program.cs +++ b/src/WebApi/Program.cs @@ -12,8 +12,10 @@ builder.Services.AddControllers(); // Database -builder.Services.AddDbContext(options => options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"), o => o.UseNodaTime())); -builder.Services.AddHealthChecks().AddNpgSql(builder.Configuration.GetConnectionString("DefaultConnection"), name: "SampleDB"); +var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") + ?? throw new InvalidOperationException("DefaultConnection is not configured."); +builder.Services.AddDbContext(options => options.UseNpgsql(connectionString, o => o.UseNodaTime())); +builder.Services.AddHealthChecks().AddNpgSql(connectionString, name: "SampleDB"); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/src/WebApi/WebApi.csproj b/src/WebApi/WebApi.csproj index 05b4fa4..f738ed4 100644 --- a/src/WebApi/WebApi.csproj +++ b/src/WebApi/WebApi.csproj @@ -1,19 +1,19 @@  - net7.0 + net9.0 enable enable - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/Application.Tests/Application.Tests.csproj b/tests/Application.Tests/Application.Tests.csproj index d1fb1fb..3e087ac 100644 --- a/tests/Application.Tests/Application.Tests.csproj +++ b/tests/Application.Tests/Application.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net9.0 enable enable @@ -10,14 +10,14 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/WebApi.Tests/WebApi.Tests.csproj b/tests/WebApi.Tests/WebApi.Tests.csproj index 6d1e749..a791c72 100644 --- a/tests/WebApi.Tests/WebApi.Tests.csproj +++ b/tests/WebApi.Tests/WebApi.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net9.0 enable enable @@ -10,14 +10,14 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all