Skip to content

Commit

Permalink
MAUI Add WinUI Unpackaged Launch & rename namespace/appname
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed May 29, 2022
1 parent 4823853 commit 7fc28ab
Show file tree
Hide file tree
Showing 23 changed files with 110 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/ST.Client.Desktop.Avalonia.App/Properties/app.manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<assemblyIdentity version="1.0.0.0" name="WattToolkit.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
Expand Down
6 changes: 3 additions & 3 deletions src/ST.Client.Maui.App/App.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:ST.Client.Maui.App"
x:Class="ST.Client.Maui.App.App">
xmlns:local="clr-namespace:System.Application.UI"
x:Class="System.Application.UI.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down
6 changes: 4 additions & 2 deletions src/ST.Client.Maui.App/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace ST.Client.Maui.App
using MauiApplication = Microsoft.Maui.Controls.Application;

namespace System.Application.UI
{
public partial class App : Application
public partial class App : MauiApplication
{
public App()
{
Expand Down
4 changes: 2 additions & 2 deletions src/ST.Client.Maui.App/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="ST.Client.Maui.App.AppShell"
x:Class="System.Application.UI.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:ST.Client.Maui.App"
xmlns:local="clr-namespace:System.Application.UI"
Shell.FlyoutBehavior="Disabled">

<ShellContent
Expand Down
2 changes: 1 addition & 1 deletion src/ST.Client.Maui.App/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ST.Client.Maui.App
namespace System.Application.UI
{
public partial class AppShell : Shell
{
Expand Down
4 changes: 2 additions & 2 deletions src/ST.Client.Maui.App/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ST.Client.Maui.App.MainPage">
x:Class="System.Application.UI.MainPage">

<ScrollView>
<VerticalStackLayout
Expand Down
2 changes: 1 addition & 1 deletion src/ST.Client.Maui.App/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ST.Client.Maui.App
namespace System.Application.UI
{
public partial class MainPage : ContentPage
{
Expand Down
4 changes: 2 additions & 2 deletions src/ST.Client.Maui.App/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace ST.Client.Maui.App
namespace System.Application.UI
{
public static class MauiProgram
public static partial class MauiProgram
{
public static MauiApp CreateMauiApp()
{
Expand Down
2 changes: 1 addition & 1 deletion src/ST.Client.Maui.App/Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Android.Content.PM;
using Android.OS;

namespace ST.Client.Maui.App
namespace System.Application.UI
{
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Android.App;
using Android.Runtime;

namespace ST.Client.Maui.App
namespace System.Application.UI
{
[Application]
public class MainApplication : MauiApplication
Expand Down
4 changes: 2 additions & 2 deletions src/ST.Client.Maui.App/Platforms/MacCatalyst/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Foundation;
using Foundation;

namespace ST.Client.Maui.App
namespace System.Application.UI
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
Expand Down
2 changes: 1 addition & 1 deletion src/ST.Client.Maui.App/Platforms/MacCatalyst/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ObjCRuntime;
using UIKit;

namespace ST.Client.Maui.App
namespace System.Application.UI
{
public class Program
{
Expand Down
2 changes: 1 addition & 1 deletion src/ST.Client.Maui.App/Platforms/Tizen/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Maui.Hosting;
using System;

namespace ST.Client.Maui.App
namespace System.Application.UI
{
class Program : MauiApplication
{
Expand Down
8 changes: 4 additions & 4 deletions src/ST.Client.Maui.App/Platforms/Tizen/tizen-manifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.companyname.ST.Client.Maui.App" version="1.0.0" api-version="7" xmlns="http://tizen.org/ns/packages">
<?xml version="1.0" encoding="utf-8"?>
<manifest package="net.steampp.app" version="1.0.0" api-version="7" xmlns="http://tizen.org/ns/packages">
<profile name="common" />
<ui-application appid="com.companyname.ST.Client.Maui.App" exec="ST.Client.Maui.App.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
<label>ST.Client.Maui.App</label>
<ui-application appid="net.steampp.app" exec="Watt Toolkit.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
<label>Watt Toolkit</label>
<icon>appicon.xhigh.png</icon>
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
</ui-application>
Expand Down
6 changes: 3 additions & 3 deletions src/ST.Client.Maui.App/Platforms/Windows/App.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<maui:MauiWinUIApplication
x:Class="ST.Client.Maui.App.WinUI.App"
<maui:MauiWinUIApplication
x:Class="System.Application.UI.WinUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:maui="using:Microsoft.Maui"
xmlns:local="using:ST.Client.Maui.App.WinUI">
xmlns:local="using:System.Application.UI.WinUI">

</maui:MauiWinUIApplication>
4 changes: 2 additions & 2 deletions src/ST.Client.Maui.App/Platforms/Windows/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace ST.Client.Maui.App.WinUI
namespace System.Application.UI.WinUI
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
Expand Down
42 changes: 42 additions & 0 deletions src/ST.Client.Maui.App/Platforms/Windows/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Runtime.InteropServices;
using WinRT;
using Microsoft.UI.Dispatching;
using WinUIApplication = Microsoft.UI.Xaml.Application;
using WinUIApp = System.Application.UI.WinUI.App;

namespace System.Application.UI
{
public static partial class MauiProgram
{
static event Action? Exit;

[DllImport("Microsoft.ui.xaml.dll")]
static extern void XamlCheckProcessRequirements();

[STAThread]
static void Main(string[] args)
{
// 不能以管理员权限启动 程序“.exe”已退出,返回值为 3221226505 (0xc0000409)。
try
{
XamlCheckProcessRequirements();
}
catch (DllNotFoundException ex)
{
// 需要安装 Windows App Runtime
// <WindowsPackageType>None</WindowsPackageType>
throw new ApplicationException("Requires Windows App Runtime to be installed.", ex);
}
ComWrappersSupport.InitializeComWrappers();
WinUIApplication.Start(p =>
{
var context = new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread());
SynchronizationContext.SetSynchronizationContext(context);
var app = new WinUIApp();
});

Exit?.Invoke();
}
}
}
2 changes: 1 addition & 1 deletion src/ST.Client.Maui.App/Platforms/Windows/app.manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="ST.Client.Maui.App.WinUI.app"/>
<assemblyIdentity version="1.0.0.0" name="WattToolkit.app"/>

<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
Expand Down
2 changes: 1 addition & 1 deletion src/ST.Client.Maui.App/Platforms/iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Foundation;

namespace ST.Client.Maui.App
namespace System.Application.UI
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
Expand Down
2 changes: 1 addition & 1 deletion src/ST.Client.Maui.App/Platforms/iOS/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ObjCRuntime;
using UIKit;

namespace ST.Client.Maui.App
namespace System.Application.UI
{
public class Program
{
Expand Down
9 changes: 9 additions & 0 deletions src/ST.Client.Maui.App/Properties/AssemblyInfo.OS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#if ANDROID
[assembly: System.Runtime.Versioning.SupportedOSPlatform("Android21.0")]
#elif WINDOWS
[assembly: System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.17763.0")]
#elif IOS
[assembly: System.Runtime.Versioning.SupportedOSPlatform("iOS10.0")]
#elif MACCATALYST
[assembly: System.Runtime.Versioning.SupportedOSPlatform("maccatalyst13.1")]
#endif
6 changes: 2 additions & 4 deletions src/ST.Client.Maui.App/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"profiles": {
"Watt Toolkit (Package)": {
"commandName": "MsixPackage",
"nativeDebugging": false
"commandName": "MsixPackage"
},
"Watt Toolkit (Unpackaged)": {
"commandName": "Project",
"nativeDebugging": false
"commandName": "Project"
}
}
}
33 changes: 23 additions & 10 deletions src/ST.Client.Maui.App/ST.Client.Maui.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,45 @@
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>ST.Client.Maui.App</RootNamespace>
<AssemblyName>Watt Toolkit</AssemblyName>
<RootNamespace>System.Application.UI</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>ST.Client.Maui.App</ApplicationTitle>
<ApplicationTitle>Watt Toolkit</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.st.client.maui.app</ApplicationId>
<ApplicationId>net.steampp.app</ApplicationId>
<ApplicationIdGuid>81D03C5E-87AB-4FAE-AC12-05192637186E</ApplicationIdGuid>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>

<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<SupportedOSPlatformVersion>14.2</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<SupportedOSPlatformVersion>21.0</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<WindowsPackageType>None</WindowsPackageType>
<DefineConstants>DISABLE_XAML_GENERATED_MAIN;$(DefineConstants)</DefineConstants>
<StartupObject>System.Application.UI.MauiProgram</StartupObject>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">
<SupportedOSPlatformVersion>6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
Expand Down

0 comments on commit 7fc28ab

Please sign in to comment.