Implement backup and restore functionality; add IBackupService and BackupService; refactor services to use DbContextFactory

This commit is contained in:
2026-04-03 10:53:53 +02:00
parent 0923c037eb
commit 387c18e834
15 changed files with 411 additions and 71 deletions

View File

@@ -2,8 +2,21 @@
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<OutputType Condition="$([MSBuild]::IsOSPlatform('Windows'))">WinExe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>$([System.DateTime]::Now.ToString('yy')).$([System.DateTime]::Now.DayOfYear)</Version>
<PublishedExeFileName>Duempelkas-v$(Version).exe</PublishedExeFileName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<DebugType>None</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
@@ -24,4 +37,11 @@
<ProjectReference Include="..\Duempelkas.App\Duempelkas.App.csproj" />
<ProjectReference Include="..\Duempelkas.Infrastructure\Duempelkas.Infrastructure.csproj" />
</ItemGroup>
<Target Name="FinalizePublishOutput" AfterTargets="Publish">
<Move SourceFiles="$(PublishDir)$(AssemblyName).exe"
DestinationFiles="$(PublishDir)$(PublishedExeFileName)"
Condition="Exists('$(PublishDir)$(AssemblyName).exe') and '$(AssemblyName).exe' != '$(PublishedExeFileName)'" />
<Touch Files="$(PublishDir)duempelkas.db" AlwaysCreate="true" Condition="!Exists('$(PublishDir)duempelkas.db')" />
</Target>
</Project>

View File

@@ -13,7 +13,8 @@ class Program
{
var appBuilder = PhotinoBlazorAppBuilder.CreateDefault(args);
var dbPath = Path.Combine(AppContext.BaseDirectory, "duempelkas.db");
var exeDirectory = Path.GetDirectoryName(Environment.ProcessPath ?? AppContext.BaseDirectory) ?? AppContext.BaseDirectory;
var dbPath = Path.Combine(exeDirectory, "duempelkas.db");
appBuilder.Services.AddInfrastructure($"Data Source={dbPath}");
appBuilder.RootComponents.Add<Duempelkas.App.Components.App>("app");