Migrate NetCore3.1 HostBuilder to .Net6.0 Builder

56 views Asked by At

Having the Program.cs of a .NET Core 3.1 application and following the migration guides I can't get the app running in .NET 6.

The Program.cs if from a CoreWCF sample and I try to bring it to this .NET6 sample.

class Program
{
    static void Main(string[] args)
    {
        IWebHost host = CreateWebHostBuilder(args).Build();
        host.Run();
    }

    // Listen on 8088 for http, and 8443 for https, 8089 for NetTcp.
    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
        .UseKestrel(options => {
            options.ListenAnyIP(Startup.HTTP_PORT);
            options.ListenAnyIP(Startup.HTTPS_PORT, listenOptions =>
            {
                listenOptions.UseHttps();
                if (Debugger.IsAttached)
                {
                    listenOptions.UseConnectionLogging();
                }
            });
        })
        .UseNetTcp(Startup.NETTCP_PORT)
        .UseStartup<Startup>();
}

How does the correct .NET 6 version look like (I can't even get it compiling).

0

There are 0 answers