Skip to content

Commit

Permalink
update for main
Browse files Browse the repository at this point in the history
new host builder pattern, now csproj updates
  • Loading branch information
davidortinau committed Oct 21, 2021
1 parent ce2696d commit e8fb9dd
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 66 deletions.
8 changes: 0 additions & 8 deletions src/WeatherTwentyOne.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31220.234
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeatherTwentyOne.WinUI", "WeatherTwentyOne.WinUI\WeatherTwentyOne.WinUI.csproj", "{202C61B5-A2D9-4817-8020-731D9F855561}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeatherTwentyOne", "WeatherTwentyOne\WeatherTwentyOne.csproj", "{07CD65EF-6238-4365-AF5D-F6D433967F48}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{70AB34BF-8F22-46E1-A505-99908DA7CD44}"
Expand All @@ -18,12 +16,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{202C61B5-A2D9-4817-8020-731D9F855561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{202C61B5-A2D9-4817-8020-731D9F855561}.Debug|Any CPU.Build.0 = Debug|Any CPU
{202C61B5-A2D9-4817-8020-731D9F855561}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{202C61B5-A2D9-4817-8020-731D9F855561}.Release|Any CPU.ActiveCfg = Release|Any CPU
{202C61B5-A2D9-4817-8020-731D9F855561}.Release|Any CPU.Build.0 = Release|Any CPU
{202C61B5-A2D9-4817-8020-731D9F855561}.Release|Any CPU.Deploy.0 = Release|Any CPU
{07CD65EF-6238-4365-AF5D-F6D433967F48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07CD65EF-6238-4365-AF5D-F6D433967F48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07CD65EF-6238-4365-AF5D-F6D433967F48}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
Expand Down
49 changes: 49 additions & 0 deletions src/WeatherTwentyOne/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Microsoft.Maui;
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Compatibility;
using Microsoft.Maui.Controls.Hosting;
using WeatherTwentyOne.Services;
using Microsoft.Maui.LifecycleEvents;

namespace WeatherTwentyOne
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts => {
fonts.AddFont("fa-solid-900.ttf", "FontAwesome");
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-SemiBold.ttf", "OpenSansSemiBold");
});
builder.ConfigureLifecycleEvents(lifecycle => {
#if WINDOWS
lifecycle
.AddWindows(windows => windows.OnLaunched((app, args) => {
MauiWinUIApplication.Current.MainWindow.SetIcon("Platforms/Windows/trayicon.ico");
}));
#endif
});

var services = builder.Services;
#if WINDOWS
services.AddSingleton<ITrayService, WinUI.TrayService>();
services.AddSingleton<INotificationService, WinUI.NotificationService>();
#elif MACCATALYST
services.AddSingleton<ITrayService, MacCatalyst.TrayService>();
services.AddSingleton<INotificationService, MacCatalyst.NotificationService>();
#endif




return builder.Build();
}
}
}
5 changes: 4 additions & 1 deletion src/WeatherTwentyOne/Platforms/Android/MainApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
using Android.App;
using Android.Runtime;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;

namespace WeatherTwentyOne
{
[Application]
public class MainApplication : MauiApplication<Startup>
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
4 changes: 3 additions & 1 deletion src/WeatherTwentyOne/Platforms/MacCatalyst/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Foundation;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;

namespace WeatherTwentyOne
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate<Startup>
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
4 changes: 2 additions & 2 deletions src/WeatherTwentyOne/Platforms/MacCatalyst/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
4 changes: 3 additions & 1 deletion src/WeatherTwentyOne/Platforms/iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Foundation;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;

namespace WeatherTwentyOne
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate<Startup>
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
40 changes: 0 additions & 40 deletions src/WeatherTwentyOne/Startup.cs

This file was deleted.

36 changes: 23 additions & 13 deletions src/WeatherTwentyOne/WeatherTwentyOne.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@
<RootNamespace>WeatherTwentyOne</RootNamespace>
<ApplicationTitle>WeatherTwentyOne</ApplicationTitle>
<ApplicationId>com.companyname.WeatherTwentyOne</ApplicationId>
<ApplicationVersion>1.0</ApplicationVersion>
<AndroidVersionCode>1</AndroidVersionCode>
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
<_FastDeploymentDiagnosticLogging>true</_FastDeploymentDiagnosticLogging>
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
<SingleProject>true</SingleProject>
<ApplicationVersion>1</ApplicationVersion>

<!-- Required for C# Hot Reload -->
<UseInterpreter Condition="'$(Configuration)' == 'Debug'">True</UseInterpreter>

<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.18362.0</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -21,15 +28,18 @@
<MauiFont Include="Resources\Fonts\*" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-maccatalyst'))">
<BundleResource Include="Platforms\MacCatalyst\trayicon.png" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
<!-- Required - WinUI does not yet have buildTransitive for everything -->
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0-experimental1" />
<PackageReference Include="Microsoft.WindowsAppSDK.Foundation" Version="1.0.0-experimental1" />
<PackageReference Include="Microsoft.WindowsAppSDK.WinUI" Version="1.0.0-experimental1" />
<PackageReference Include="Microsoft.WindowsAppSDK.InteractiveExperiences" Version="1.0.0-experimental1" NoWarn="NU1701" />
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.0.26-experimental1" />
</ItemGroup>

<PropertyGroup>
<RuntimeIdentifier Condition="$(TargetFramework.Contains('-ios'))">iossimulator-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$(TargetFramework.Contains('-maccatalyst'))">maccatalyst-x64</RuntimeIdentifier>
<InvariantGlobalization Condition="$(TargetFramework.Contains('-maccatalyst'))">true</InvariantGlobalization>
<UseInterpreter Condition="$(TargetFramework.Contains('-android'))">false</UseInterpreter>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
<OutputType>WinExe</OutputType>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

</Project>

0 comments on commit e8fb9dd

Please sign in to comment.