Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Raymond Brink 2 posts 22 karma points
    Sep 20, 2022 @ 09:43
    Raymond Brink
    0

    Running Umbraco v10 in .NET 6' minimal hosting model

    Is it possible to run Umbraco v10 in .NET 6' minimal hosting model? By this I mean the new way of bootstrapping .NET 6 applications with just a Program.cs file instead of a Program.cs and Startup.cs, as it was for .NET 5.

    I've come this far, but keep running into errors related to ambiguous controller registrations:

    var builder = WebApplication.CreateBuilder(args);
    
    builder.Services.AddUmbraco(builder.Environment, builder.Configuration)
        .AddBackOffice()
        .AddWebsite()
        .AddComposers()
        .Build();
    builder.Services.AddRazorPages();
    
    var app = builder.Build();
    
    if (!app.Environment.IsDevelopment())
    {
        app.UseExceptionHandler("/Error");
        // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
        app.UseHsts();
    }
    
    app.UseHttpsRedirection();
    app.UseStaticFiles();
    
    app.UseUmbraco()
        .WithMiddleware(u =>
        {
            u.UseBackOffice();
            u.UseWebsite();
        })
        .WithEndpoints(u =>
        {
            u.UseInstallerEndpoints();
            u.UseBackOfficeEndpoints();
            u.UseWebsiteEndpoints();
        });
    app.UseUmbracoRouting();
    
    app.UseRouting();
    
    app.UseAuthorization();
    
    app.MapRazorPages();
    
    //await app.InitializeApplicationAsync();
    app.Run();
    

    I keep getting this error on app.Run():

    System.ArgumentNullException: 'Value cannot be null. (Parameter 'provider')'

    What am I missing here? Thanks in advance!

    Raymond

  • Michal 4 posts 74 karma points
    Sep 20, 2022 @ 10:42
    Michal
    0

    I tried and failed. I created a startup file like in core 5.0

      public class Program
        {
            public static void Main(string[] args)
                => CreateHostBuilder(args)
                    .Build()
                    .Run();
    
        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureUmbracoDefaults()
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStaticWebAssets();
                    webBuilder.UseStartup<Startup>();
                })
                .ConfigureLogging(logging =>
                {
                    logging.ClearProviders();
                    logging.SetMinimumLevel(LogLevel.Trace);
                })
                .UseNLog();
    }
    

    startup.cs

      services.AddUmbraco(_env, _config)
                    .AddBackOffice()
                    .AddWebsite()
                    .AddComposers()
            // .SetBackOfficeUserManager<CustomBackOfficeUserManager>()
            // Add ConfigureAuthentication
            .ConfigureAuthentication()
                    .Build();
    
  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Sep 20, 2022 @ 11:12
    Sebastiaan Janssen
    0

    Minimal hosting model may or may not be supported yet, someone seems to have made it work in the comments here: https://github.com/umbraco/Umbraco-CMS/issues/12445#issuecomment-1227264825

  • Raymond Brink 2 posts 22 karma points
    Sep 20, 2022 @ 12:24
    Raymond Brink
    0

    Thanks Sebastiaan. Even though that work-around does run Umbraco 10, it doesn't play nice with the AppModule paradigm used by ABP.io.

    I'd be interested to see if both can be combined into one project.

Please Sign in or register to post replies

Write your reply to:

Draft