Add cache and build configuration files for .NET projects
- Created new cache JSON files for rjsmcshtml, rjsmrazor, and rpswa in both net10.0 and net7.0 directories. - Added static web assets build configuration files in both net10.0 and net7.0 directories. - Included build endpoint configurations and cache files for static web assets. - Ensured all new files are properly initialized with relevant properties and hashes.
This commit is contained in:
33
Program.cs
33
Program.cs
@@ -5,6 +5,7 @@ using Microsoft.SelfService.Portal.Core.API.Events;
|
||||
using Microsoft.SelfService.Portal.Core.API.Events.Interfaces;
|
||||
using Microsoft.SelfService.Portal.Core.API.Interfaces;
|
||||
using Microsoft.SelfService.Portal.Core.API.Repository;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
@@ -32,7 +33,7 @@ builder.Services.AddScoped<ITemplateInterface, TemplateRepository>();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
||||
builder.Services.AddAutoMapper(_ => { }, AppDomain.CurrentDomain.GetAssemblies());
|
||||
|
||||
builder.Services.AddDbContext<DataContext>(options =>
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("Context") ?? throw new InvalidOperationException("Connection string 'Context' not found.")));
|
||||
@@ -49,6 +50,11 @@ builder.Services.AddAuthorization(options =>
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
var frontendDistPath = Path.GetFullPath(Path.Combine(
|
||||
app.Environment.ContentRootPath,
|
||||
"..",
|
||||
"Microsoft.SelfService.Portal.Web",
|
||||
"dist"));
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
@@ -59,8 +65,33 @@ if (app.Environment.IsDevelopment())
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
if (Directory.Exists(frontendDistPath))
|
||||
{
|
||||
var frontendDistProvider = new PhysicalFileProvider(frontendDistPath);
|
||||
|
||||
app.UseDefaultFiles(new DefaultFilesOptions
|
||||
{
|
||||
FileProvider = frontendDistProvider
|
||||
});
|
||||
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
FileProvider = frontendDistProvider
|
||||
});
|
||||
}
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
if (Directory.Exists(frontendDistPath))
|
||||
{
|
||||
app.MapFallback(async context =>
|
||||
{
|
||||
context.Response.ContentType = "text/html";
|
||||
await context.Response.SendFileAsync(Path.Combine(frontendDistPath, "index.html"));
|
||||
}).AllowAnonymous();
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user