Skip to content

Upgraded BaGet solution from .NET Core 3.1 to .NET 8#805

Open
MarcBanyard wants to merge 2 commits into
loic-sharma:mainfrom
MarcBanyard:main
Open

Upgraded BaGet solution from .NET Core 3.1 to .NET 8#805
MarcBanyard wants to merge 2 commits into
loic-sharma:mainfrom
MarcBanyard:main

Conversation

@MarcBanyard

@MarcBanyard MarcBanyard commented Dec 3, 2025

Copy link
Copy Markdown

BaGet .NET 8 Upgrade - Changes Summary

Overview

Upgraded BaGet solution from .NET Core 3.1 to .NET 8, updating all project files, dependencies, and resolving compatibility issues.

Project Files (.csproj)

Source Projects

  • src/BaGet/BaGet.csproj: Updated TargetFramework from netcoreapp3.1 to net8.0. Added <UseRidGraph>true</UseRidGraph> to resolve NETSDK1206 warning.
  • src/BaGet.Web/BaGet.Web.csproj: Updated TargetFramework from netcoreapp3.1 to net8.0. Added <AddRazorSupportForMvc>true</AddRazorSupportForMvc>.
  • src/BaGet.Protocol/BaGet.Protocol.csproj: Updated TargetFramework from netstandard2.0 to net8.0. Removed System.Text.Json package reference (included in .NET 8).
  • src/BaGet.Core/BaGet.Core.csproj: Updated TargetFramework from netstandard2.0 to net8.0.
  • src/BaGet.Database.MySql/BaGet.Database.MySql.csproj: Updated TargetFramework from netstandard2.0 to net8.0. Updated Pomelo.EntityFrameworkCore.MySql to 8.0.2.
  • src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj: Updated TargetFramework from netstandard2.0 to net8.0. Updated Npgsql.EntityFrameworkCore.PostgreSQL to 8.0.0.
  • src/BaGet.Azure/BaGet.Azure.csproj: Updated TargetFramework from netstandard2.0 to net8.0. Added <UseRidGraph>true</UseRidGraph> to resolve NETSDK1206 warning.
  • All other source projects (BaGet.Aws, BaGet.Gcp, BaGet.Aliyun, BaGet.Database.Sqlite, BaGet.Database.SqlServer): Updated TargetFramework from netstandard2.0 to net8.0.

Test Projects

  • All test projects (BaGet.Tests, BaGet.Core.Tests, BaGet.Web.Tests, BaGet.Protocol.Tests): Updated TargetFramework from netcoreapp3.1 to net8.0.

Directory.Build.props

src/Directory.Build.props

  • Changed LangVersion from latest to 12.0 (C# 12).
  • Updated package versions:
    • MicrosoftAspNetCorePackageVersion: 8.0.0
    • MicrosoftEntityFrameworkCorePackageVersion: 8.0.0
    • MicrosoftExtensionsPackageVersion: 8.0.0
    • NuGetPackageVersion: 6.10.0
    • Microsoft.SourceLink.GitHub: 8.0.0

tests/Directory.Build.props

  • Changed LangVersion from latest to 12.0 (C# 12).
  • Updated package versions:
    • MicrosoftAspNetCorePackageVersion: 8.0.0
    • NewtonsoftJsonPackageVersion: 13.0.3
    • NuGetPackageVersion: 6.10.0
    • XUnitPackageVersion: 2.9.0
    • coverlet.collector: 6.0.2
    • Microsoft.NET.Test.Sdk: 17.10.0
    • Moq: 4.20.70

Dockerfile

  • Updated base image from mcr.microsoft.com/dotnet/aspnet:3.1 to mcr.microsoft.com/dotnet/aspnet:8.0.
  • Updated SDK image from mcr.microsoft.com/dotnet/sdk:3.1 to mcr.microsoft.com/dotnet/sdk:8.0.

Code Changes

Entity Framework Core Query Optimisation

File: src/BaGet.Core/PackageDatabase.cs

  • Added .AsSplitQuery() to FindAsync, FindOrNullAsync, and HardDeletePackageAsync methods to resolve EF Core warning about multiple collection includes and improve query performance.

MySQL Database Provider Updates

File: src/BaGet.Database.MySql/MySqlApplicationExtensions.cs

  • Updated UseMySql call to use ServerVersion.AutoDetect() instead of passing connection string directly (required by Pomelo EF Core 8).

File: src/BaGet.Database.MySql/MySqlContext.cs

  • Changed namespace from MySql.Data.MySqlClient to MySqlConnector for MySqlException (Pomelo EF Core 8 uses MySqlConnector).

Obsolete API Updates

File: src/BaGet.Web/Extensions/IServiceCollectionExtensions.cs

  • Removed obsolete SetCompatibilityVersion(CompatibilityVersion.Version_3_0) call.
  • Replaced obsolete JsonSerializerOptions.IgnoreNullValues = true with DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull.

Routing Fixes

File: src/BaGet.Web/BaGetEndpointBuilder.cs

  • Added /packages route mapping to redirect to Index page.
  • Added using System.Threading.Tasks; for async route handler.

File: src/BaGet.Web/Pages/Index.cshtml

  • Removed asp-route-version from package links so clicking a package navigates to /packages/{id} (latest version).

File: src/BaGet.Web/Pages/Package.cshtml

  • Added asp-route-id to version links so clicking a specific version correctly navigates to /packages/{id}/{version}.

Test Fixes

File: tests/BaGet.Web.Tests/Pages/PackageModelFacts.cs

  • Replaced Assert.Equal(1, ...Count) with Assert.Single(...) to resolve xUnit analyser warning.

Documentation

readme.md

  • Updated "Develop" section:
    • Changed ".NET Core SDK" to ".NET 8 SDK".
    • Removed Node.js requirement (frontend dependencies managed by LibMan).
    • Removed npm install step.
    • Added dotnet clean, dotnet restore, dotnet build steps.
    • Updated dotnet run command instructions.
  • Restored missing "Features" section content (Dockerized, Cloud ready, Read-through caching, Nuget.org indexing, Private feeds).

Warnings Resolved

  1. NETSDK1206: Resolved by adding <UseRidGraph>true</UseRidGraph> to projects with transitive dependencies using deprecated RIDs.
  2. NU1903: Resolved by removing explicit System.Text.Json package reference (included in .NET 8).
  3. ASP5001/CS0618: Resolved by removing obsolete SetCompatibilityVersion call.
  4. SYSLIB0020: Resolved by replacing obsolete IgnoreNullValues with DefaultIgnoreCondition.
  5. xUnit2013: Resolved by using Assert.Single() instead of Assert.Equal(1, ...).
  6. Microsoft.EntityFrameworkCore.Query[20504]: Resolved by adding .AsSplitQuery() to queries with multiple collection includes.

Breaking Changes Addressed

  • Pomelo EF Core 8: Updated MySQL provider usage to match new API requirements.
  • EF Core 8: Updated target frameworks from netstandard2.0 to net8.0 for projects using EF Core.
  • ASP.NET Core 8: Removed compatibility version settings and updated JSON serialisation options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant