Move to Minimal Hosting Model in a backwards compatible way (#14656)
* Use minimal hosting model * Make CoreRuntime backward compatible to the old hosting model * Remove unneccessary methods from interface again * Pushed the timeout for E2E test to 120 minutes instead of 60 * Updated the preview version from 6 to 7 * Explicitly call BootUmbracoAsync * Add CreateUmbracoBuilder extension method * Do not add IRuntime as hosted service when using WebApplication/WebApplicationBuilder * Set StaticServiceProvider.Instance before booting * Ensure Umbraco is booted and StaticServiceProvider.Instance is set before configuring middleware * Do not enable static web assets on production environments * Removed root namespace from viewImports --------- Co-authored-by: Andreas Zerbst <andr317c@live.dk> Co-authored-by: Ronald Barendse <ronald@barend.se>
This commit is contained in:
@@ -1,19 +1,36 @@
|
||||
namespace Umbraco.Cms.Web.UI
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
=> CreateHostBuilder(args)
|
||||
.Build()
|
||||
.Run();
|
||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureUmbracoDefaults()
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStaticWebAssets();
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
}
|
||||
builder.CreateUmbracoBuilder()
|
||||
.AddBackOffice()
|
||||
.AddWebsite()
|
||||
.AddDeliveryApi()
|
||||
.AddComposers()
|
||||
.Build();
|
||||
|
||||
WebApplication app = builder.Build();
|
||||
|
||||
await app.BootUmbracoAsync();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
#if (UseHttpsRedirect)
|
||||
app.UseHttpsRedirection();
|
||||
#endif
|
||||
|
||||
app.UseUmbraco()
|
||||
.WithMiddleware(u =>
|
||||
{
|
||||
u.UseBackOffice();
|
||||
u.UseWebsite();
|
||||
})
|
||||
.WithEndpoints(u =>
|
||||
{
|
||||
u.UseInstallerEndpoints();
|
||||
u.UseBackOfficeEndpoints();
|
||||
u.UseWebsiteEndpoints();
|
||||
});
|
||||
|
||||
await app.RunAsync();
|
||||
|
||||
Reference in New Issue
Block a user