feat(01-01): create WPF solution with Generic Host entry point and NuGet packages
- SharepointToolbox.slnx solution with WPF project - net10.0-windows target, PublishTrimmed=false, StartupObject set - App.xaml StartupUri removed, App demoted from ApplicationDefinition to Page - App.xaml.cs: [STAThread] Main with Host.CreateDefaultBuilder + Serilog rolling file - All NuGet packages: CommunityToolkit.Mvvm 8.4.2, MSAL 4.83.3, PnP.Framework 1.18.0, Serilog 4.3.1 - Build: 0 errors, 0 warnings
This commit is contained in:
40
SharepointToolbox/App.xaml.cs
Normal file
40
SharepointToolbox/App.xaml.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using System.Windows;
|
||||
|
||||
namespace SharepointToolbox;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
using IHost host = Host.CreateDefaultBuilder(args)
|
||||
.UseSerilog((ctx, cfg) => cfg
|
||||
.WriteTo.File(
|
||||
System.IO.Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"SharepointToolbox", "logs", "app-.log"),
|
||||
rollingInterval: RollingInterval.Day,
|
||||
retainedFileCountLimit: 30))
|
||||
.ConfigureServices(RegisterServices)
|
||||
.Build();
|
||||
|
||||
host.Start();
|
||||
App app = new();
|
||||
app.InitializeComponent();
|
||||
app.MainWindow = host.Services.GetRequiredService<MainWindow>();
|
||||
app.MainWindow.Visibility = Visibility.Visible;
|
||||
app.Run();
|
||||
}
|
||||
|
||||
private static void RegisterServices(HostBuilderContext ctx, IServiceCollection services)
|
||||
{
|
||||
// Placeholder — services registered in subsequent plans
|
||||
services.AddSingleton<MainWindow>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user