Skip to content

Cannot set environment because IHost is already constructed in .NET 6 web app #75

@azborgonovo

Description

@azborgonovo

Symptom

Running a command like dotnet run -- db-patch file.sql --environment Staging results in the following error:

image

Context

I tried to set up my .NET 6 web application as described in the docs. In summary, my Program.cs file looks like the following:

var builder = WebApplication.CreateBuilder(args);
builder.Host.ApplyOaktonExtensions();
// ... other changes in the host builder (e.g. builder.Services.AddAuthentication())
var app = builder.Build();
// ... changes in the app (e.g. app.UseAuthentication())
return await app.RunOaktonCommands(args);

My development environment is a macOS with Apple silicon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions