Skip to content

Conversation

@LoopedBard3
Copy link
Contributor

@LoopedBard3 LoopedBard3 commented Dec 16, 2025

Update dependencies and clean up leftover warnings when building Benchmarks.csproj. This adds support for net11.0 when building the Benchmarks.csproj project with a clean build. This should also fix failing tech-empower testing in the optimization repo (or at least get us further along in the test).

The decently sized Program.cs change is really just taking the previous code and putting it inside of the ConfigureWebHost function.

When building net11, the warnings that were cleaned up were:

dotnet build -c Release -f net11.0 /p:TargetFramework=net11.0
    info NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  Benchmarks net11.0 succeeded with 4 warning(s) (26.3s) → bin\Release\net11.0\Benchmarks.dll
    C:\Users\<user>\repos\benchmarks\src\Benchmarks\Program.cs(58,38): warning ASPDEPR004: 'WebHostBuilder' is obsolete: 'WebHostBuilder is deprecated in favor of HostBuilder and WebApplicationBuilder. For more information, visit https://aka.ms/aspnet/deprecate/004.' (https://aka.ms/aspnet/deprecate/004)
    C:\Users\<user>\repos\benchmarks\src\Benchmarks\Program.cs(151,27): warning ASPDEPR008: 'IWebHostBuilder.Build()' is obsolete: 'IWebHost is obsolete. Use IHost instead. For more information, visit https://aka.ms/aspnet/deprecate/008.' (https://aka.ms/aspnet/deprecate/008)
    C:\Users\<user>\repos\benchmarks\src\Benchmarks\Data\World.cs(13,10): warning DAP043: Attach the [UseColumnAttribute] attribute to make Dapper consider [Column] (https://aot.dapperlib.dev/rules/DAP043)
    C:\Users\<user>\repos\benchmarks\src\Benchmarks\Data\World.cs(20,10): warning DAP043: Attach the [UseColumnAttribute] attribute to make Dapper consider [Column] (https://aot.dapperlib.dev/rules/DAP043)

Build succeeded with 4 warning(s) in 26.7s

I tested building this with the latest net11 alpha locally and it built successfully. What other testing should be done before merging this?

@LoopedBard3 LoopedBard3 self-assigned this Dec 16, 2025
@LoopedBard3 LoopedBard3 added dependencies Pull requests that update a dependency file .NET Pull requests that update .net code labels Dec 16, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates dependencies and resolves build warnings to add support for .NET 11.0 in the Benchmarks project. The changes modernize the hosting infrastructure by migrating from the deprecated WebHostBuilder to HostBuilder with ConfigureWebHost, and update package references to support .NET 10.0 and 11.0.

Key Changes:

  • Refactored Program.cs to use HostBuilder.ConfigureWebHost() instead of deprecated WebHostBuilder directly
  • Added UseColumnAttribute to Dapper-mapped properties to resolve DAP043 warnings
  • Updated dependency versions for .NET 9.0, 10.0, and 11.0 packages

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/Benchmarks/Program.cs Migrated from deprecated WebHostBuilder to HostBuilder with ConfigureWebHost wrapper to support .NET 11.0
src/Benchmarks/Data/World.cs Added UseColumnAttribute to properties with Column attribute to fix Dapper DAP043 warnings
src/Benchmarks/Benchmarks.csproj Added new ItemGroup condition for net10.0/net11.0 target frameworks with updated package versions
build/dependencies.props Updated package versions for .NET 9.0, added version 10.0/11.0 dependencies, removed unused Pomelo MySQL packages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +69 to +76
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0' or '$(TargetFramework)' == 'net11.0'">
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(NpgsqlEntityFrameworkCorePostgreSQLVersion100)" />
<PackageReference Include="Npgsql" Version="$(NpgsqlVersion100)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(MicrosoftEntityFrameworkCoreSqlServerVersion100)" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="$(MicrosoftDataSqlClientVersion100)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="$(MicrosoftEntityFrameworkCoreSqliteVersion100)" />
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting.IIS" Version="$(MicrosoftIISTestingVersion100)" />
</ItemGroup>
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition groups net10.0 and net11.0 together, but net11.0 should use MicrosoftIISTestingVersion110 instead of MicrosoftIISTestingVersion100. Consider splitting this into two separate ItemGroup conditions: one for net10.0 using Version100 variables, and another for net11.0 using Version110 for Microsoft.AspNetCore.Server.IntegrationTesting.IIS (while other packages can continue using Version100 if no Version110 equivalents are defined).

Copilot uses AI. Check for mistakes.
…eption: Unable to resolve service for type 'Benchmarks.Configuration.Scenarios' while attempting to activate 'Benchmarks.Startup'.
@sebastienros
Copy link
Member

sebastienros commented Dec 16, 2025

Looks good, please try to run a Benchmark though that triggers the Benchmarks.csproj app (Json middleware a.k.a Json) on net8, 10 and 11. 11 might fail because of crank support.

@LoopedBard3
Copy link
Contributor Author

Cool, I will run those tests now that I have a version of the app that is building and running locally (took a few iterations to get past the System.InvalidOperationException: Unable to resolve service for type... error and ensure the final warnings could be suppressed. The set of changes for this was mostly to move from trying to Inject Scenarios into Startup, which is not available with the new classes, to instead getting and setting Scenarios in ConfigureServices and moving the UseStartup to after ConfigureServices as the StartupService depends on the Scenarios Singleton. The high-level changes that require this is HostBuilder limiting Startups potential DI candidates to IConfiguration, IHostEnvironment and IWebHostEnvironment. More Info.

With this in mind, if anyone has ideas for other or preferred approaches they would be greatly appreciated. I can also not make those changes in this PR and can make another PR to deal with the deprecation warnings.

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

Labels

dependencies Pull requests that update a dependency file .NET Pull requests that update .net code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants