Added preprocessor directives to handle both development & release versions

This commit is contained in:
tsommer committed 2024-05-18 21:50:46 +02:00
1 parent 8dd6a2f898
commit cb3bb42aa4
2 files changed
+27 -1

No files matched your search

+14 -1
View File
@@ -38,15 +38,28 @@ builder.Services.AddRazorComponents()
var port = args.Length > 0 ? args[0] : "5000";
builder.WebHost.UseUrls($"http://localhost:{port}");
var fileProvider = new ManifestEmbeddedFileProvider(Assembly.GetAssembly(type: typeof(Program))!, "wwwroot");
#if DEBUG
builder.WebHost.UseWebRoot("wwwroot");
builder.WebHost.UseStaticWebAssets();
#endif
var app = builder.Build();
app.Use(Redirect.HandlerContentAsync);
#if DEBUG
app.UseStaticFiles();
#else
var fileProvider = new ManifestEmbeddedFileProvider(Assembly.GetAssembly(type: typeof(Program))!, "wwwroot");
app.UseDeveloperExceptionPage();
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = fileProvider,
RequestPath = string.Empty,
});
#endif
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();