.NET Core MVC .UseSentry isn't on IWebHostBuilder

Hello everyone

I am new to Sentry and want to give it a go. The initial setup instructions said to do:

But that did not work, I then did some Googling and found this repo on GitHub.

I am trying to replicate the code in my Program.cs like so:

public static IHostBuilder CreateHostBuilder(string[] args) =>
      .ConfigureWebHostDefaults(webBuilder =>
          .UseSentry(o =>
            o.MaxBreadcrumbs = 200;
            o.DecompressionMethods = DecompressionMethods.None;
            o.MaxQueueItems = 100;
            o.ShutdownTimeout = TimeSpan.FromSeconds(5);
            o.MinimumEventLevel = LogLevel.Error;

But I’m getting a build error, it apparently doesn’t recognise .UseSentry() even though I have the nuget package installed.

What am I missing?

Sentry also has a project type ASP.NET Core (you chose plain C#) which has the right init code there for you.

It also suggests you install Sentry.AspNetCore which includes Sentry plus extra stuff like request information from ASP.NET Core. This package also integrates easily with the app startup. It adds the extension method you’re trying to use UseSentry() and also reads configuration from IConfiguration so you can configure Sentry via appsettings.json

Here are the docs: https://docs.sentry.io/platforms/dotnet/aspnetcore/