Windows build not working as of now
cyborgdennett opened this issue · comments
Edit:
After commenting out everything from MauiProgram.cs that didn't work in the build, It worked!
Noticed the same thing from here. I think there might be an issue with the preprocessor directives. The Windows code doesn't even light up when I switch the Framework to Windows
The project builds and runs on Windows with a few changes:
// In MauiWinUIWindowExtensions.cs
public static IntPtr GetNativeWindowHandle(this Microsoft.Maui.Controls.Window window)
{
var nativeWindow = window.Handler.NativeView.As<IWindowNative>();
return nativeWindow.WindowHandle;
}
// In TrayService.cs
public void Initialize()
{
tray = new WindowsTrayIcon("Platforms/Windows/trayicon.ico");
tray.LeftClick = () => {
var mainWindow = (Microsoft.Maui.Controls.Window)MauiWinUIApplication.Current.Application.Windows[0];
mainWindow.BringToFront();
ClickHandler?.Invoke();
};
}
// In MauiProgram.cs
// add:
using WeatherTwentyOne.Services;
// modify:
#if WINDOWS
lifecycle
.AddWindows(windows => windows.OnLaunched((app, args) => {
var mainWindow = (Microsoft.Maui.Controls.Window)MauiWinUIApplication.Current.Application.Windows[0];
mainWindow.SetIcon("Platforms/Windows/trayicon.ico");
}));
#endif