net9 Update
This commit is contained in:
8
.idea/.idea.FoodsharingSiegen/.idea/misc.xml
generated
8
.idea/.idea.FoodsharingSiegen/.idea/misc.xml
generated
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="SwUserDefinedSpecifications">
|
|
||||||
<option name="specTypeByUrl">
|
|
||||||
<map />
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.16.0" />
|
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.7.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
59
FoodsharingSiegen.Server/Extensions.cs
Normal file
59
FoodsharingSiegen.Server/Extensions.cs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
using FoodsharingSiegen.Server.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration.Json;
|
||||||
|
|
||||||
|
namespace FoodsharingSiegen.Server
|
||||||
|
{
|
||||||
|
public static class Extensions
|
||||||
|
{
|
||||||
|
#region Public Method AddDatabaseContext
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configures the application's data access layer by setting up and registering a database context using SQLite.
|
||||||
|
/// Ensures the database file is stored within the application's base directory under a "data" folder.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="builder">An instance of <see cref="WebApplicationBuilder" /> used to configure the application's services and resources.</param>
|
||||||
|
public static void AddDatabaseContext(this WebApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
var dataDirectory = Path.Combine(AppContext.BaseDirectory, "data");
|
||||||
|
if (!Directory.Exists(dataDirectory)) Directory.CreateDirectory(dataDirectory);
|
||||||
|
|
||||||
|
var dbPath = Path.Combine(dataDirectory, "app.db");
|
||||||
|
var connectionString = $"Data Source={dbPath}";
|
||||||
|
|
||||||
|
builder.Services.AddDbContextFactory<FsContext>(options =>
|
||||||
|
options.UseSqlite(connectionString));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Method LoadAppSettings
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads application settings from JSON configuration files located in a designated "config" directory.
|
||||||
|
/// Clears existing JSON configuration files and ensures settings from the specified files are applied.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="builder">An instance of <see cref="WebApplicationBuilder" /> used to configure and load application settings.</param>
|
||||||
|
public static void LoadAppSettings(this WebApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
// Clear loaded json files
|
||||||
|
foreach (var configurationSource in builder.Configuration.Sources.Where(x => x is JsonConfigurationSource).ToList())
|
||||||
|
builder.Configuration.Sources.Remove(configurationSource);
|
||||||
|
|
||||||
|
// Define the directory where your appsettings files reside
|
||||||
|
var configDir = Path.Combine(builder.Environment.ContentRootPath, "config");
|
||||||
|
|
||||||
|
// Check if the directory exists
|
||||||
|
if (Directory.Exists(configDir))
|
||||||
|
{
|
||||||
|
// Get all JSON files that start with "appsettings" in the directory and its subdirectories
|
||||||
|
var configFiles = Directory.EnumerateFiles(configDir, "appsettings*.json", SearchOption.AllDirectories);
|
||||||
|
|
||||||
|
// Add each file to the configuration
|
||||||
|
foreach (var file in configFiles) builder.Configuration.AddJsonFile(file, true, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -19,14 +19,14 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="LibSassBuilder" Version="2.0.1" />
|
<PackageReference Include="LibSassBuilder" Version="2.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.1">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.1" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.3" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.1" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.3" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.16.0" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.7.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -20,11 +20,12 @@
|
|||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
|
||||||
<link href="css/all.min.css" rel="stylesheet" />
|
<link href="css/all.min.css" rel="stylesheet" />
|
||||||
<link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
|
<link href="_content/Blazorise/blazorise.css?v=1.7.5.0" rel="stylesheet" />
|
||||||
<link href="_content/Blazorise.Material/blazorise.material.css" rel="stylesheet" />
|
<link href="_content/Blazorise.Material/blazorise.material.css?v=1.7.5.0" rel="stylesheet" />
|
||||||
<link href="_content/Blazorise.Icons.Material/blazorise.icons.material.css" rel="stylesheet" />
|
<link href="_content/Blazorise.Icons.Material/blazorise.icons.material.css?v=1.7.5.0" rel="stylesheet" />
|
||||||
<link href="_content/Blazorise.Snackbar/blazorise.snackbar.css" rel="stylesheet" />
|
<link href="_content/Blazorise.Snackbar/blazorise.snackbar.css" rel="stylesheet" />
|
||||||
|
|
||||||
|
|
||||||
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered"/>
|
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -43,6 +44,6 @@
|
|||||||
|
|
||||||
<script src="_framework/blazor.server.js"></script>
|
<script src="_framework/blazor.server.js"></script>
|
||||||
<script src="_content/Blazorise/blazorise.js"></script>
|
<script src="_content/Blazorise/blazorise.js"></script>
|
||||||
<script src="_content/Blazorise.Material/blazorise.material.js"></script>
|
<script src="_content/Blazorise.Material/blazorise.material.js?v=1.7.5.0"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Blazorise;
|
using Blazorise;
|
||||||
using Blazorise.Icons.Material;
|
using Blazorise.Icons.Material;
|
||||||
using Blazorise.Material;
|
using Blazorise.Material;
|
||||||
|
using FoodsharingSiegen.Server;
|
||||||
using FoodsharingSiegen.Server.Auth;
|
using FoodsharingSiegen.Server.Auth;
|
||||||
using FoodsharingSiegen.Server.Data;
|
using FoodsharingSiegen.Server.Data;
|
||||||
using FoodsharingSiegen.Server.Data.Service;
|
using FoodsharingSiegen.Server.Data.Service;
|
||||||
@@ -9,14 +10,15 @@ using Microsoft.AspNetCore.Components.Authorization;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
builder.LoadAppSettings();
|
||||||
|
|
||||||
builder.WebHost.UseUrls("http://+:8700");
|
builder.WebHost.UseUrls("http://+:8700");
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddRazorPages();
|
builder.Services.AddRazorPages();
|
||||||
builder.Services.AddServerSideBlazor();
|
builder.Services.AddServerSideBlazor();
|
||||||
builder.Services.AddSingleton<WeatherForecastService>();
|
builder.Services.AddSingleton<WeatherForecastService>();
|
||||||
builder.Services.AddDbContextFactory<FsContext>(opt =>
|
builder.AddDatabaseContext();
|
||||||
opt.UseSqlite($"Data Source=app.db"));
|
|
||||||
|
|
||||||
// DI
|
// DI
|
||||||
builder.Services.AddScoped<LocalStorageService>();
|
builder.Services.AddScoped<LocalStorageService>();
|
||||||
@@ -28,8 +30,13 @@ builder.Services.AddScoped<AuthService>();
|
|||||||
builder.Services.AddScoped<UserService>();
|
builder.Services.AddScoped<UserService>();
|
||||||
builder.Services.AddScoped<ProspectService>();
|
builder.Services.AddScoped<ProspectService>();
|
||||||
|
|
||||||
|
builder.Services
|
||||||
builder.Services.AddBlazorise( options => { options.Immediate = true; }).AddMaterialProviders().AddMaterialIcons();
|
.AddBlazorise( options =>
|
||||||
|
{
|
||||||
|
options.Immediate = true;
|
||||||
|
} )
|
||||||
|
.AddMaterialProviders()
|
||||||
|
.AddMaterialIcons();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "http://localhost:8700",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
|||||||
9
FoodsharingSiegen.Server/config/appsettings.json
Normal file
9
FoodsharingSiegen.Server/config/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Kestrel": {
|
||||||
|
"Endpoints": {
|
||||||
|
"Http": {
|
||||||
|
"Url": "http://+:56000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Blazorise" Version="1.2.0"/>
|
<PackageReference Include="Blazorise" Version="1.7.5"/>
|
||||||
<PackageReference Include="Blazorise.DataGrid" Version="1.2.0"/>
|
<PackageReference Include="Blazorise.DataGrid" Version="1.7.5"/>
|
||||||
<PackageReference Include="Blazorise.Snackbar" Version="1.2.0"/>
|
<PackageReference Include="Blazorise.Snackbar" Version="1.7.5"/>
|
||||||
<PackageReference Include="Blazorise.Icons.Material" Version="1.2.0"/>
|
<PackageReference Include="Blazorise.Icons.Material" Version="1.7.5"/>
|
||||||
<PackageReference Include="Blazorise.Components" Version="1.2.0"/>
|
<PackageReference Include="Blazorise.Components" Version="1.7.5"/>
|
||||||
<PackageReference Include="Blazorise.Material" Version="1.2.0"/>
|
<PackageReference Include="Blazorise.Material" Version="1.7.5"/>
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.16.0"/>
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.7.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user