Skip to content

Commit

Permalink
Merge pull request #303 from unoplatform/mergify/bp/legacy/4x/pr-291
Browse files Browse the repository at this point in the history
feat: Enabling all platforms when selecting maui (backport #291)
  • Loading branch information
nickrandolph authored Sep 20, 2023
2 parents f9a1223 + 5ad94f3 commit e9f401b
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 36 deletions.
4 changes: 2 additions & 2 deletions build/templates/package-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ steps:
$workloadRestore = 'https://maui.blob.core.windows.net/metadata/rollbacks/7.0.92.json'
if ($templateArgs.Contains('net8')) {
$dotnetVersion = '8.0.100-preview.7.23376.3'
$workloadRestore = 'https://maui.blob.core.windows.net/metadata/rollbacks/8.0.0-preview.7.8842.json'
$dotnetVersion = '8.0.100-rc.1.23463.5'
$workloadRestore = 'https://maui.blob.core.windows.net/metadata/rollbacks/8.0.0-rc.1.9171.json'
}
Write-Host "DotNetVersion = $dotnetVersion"
Expand Down
37 changes: 31 additions & 6 deletions src/Uno.Templates/content/unoapp/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -1032,12 +1032,12 @@
"useGtk": {
"type": "computed",
"datatype": "bool",
"value": "((!mauiEmbedding) && platforms == gtk)"
"value": "(platforms == gtk)"
},
"useLinuxFb": {
"type": "computed",
"datatype": "bool",
"value": "((!mauiEmbedding) && platforms == linux-fb)"
"value": "(platforms == linux-fb)"
},
"useAndroid": {
"type": "computed",
Expand All @@ -1052,7 +1052,7 @@
"useMacOS": {
"type": "computed",
"datatype": "bool",
"value": "((!mauiEmbedding) && platforms == macos)"
"value": "(platforms == macos)"
},
"useMacCatalyst": {
"type": "computed",
Expand All @@ -1067,7 +1067,7 @@
"useWasm": {
"type": "computed",
"datatype": "bool",
"value": "((!mauiEmbedding) && platforms == wasm)"
"value": "(platforms == wasm)"
},
"useWinAppSdk": {
"type": "computed",
Expand All @@ -1077,7 +1077,32 @@
"useWpf": {
"type": "computed",
"datatype": "bool",
"value": "((!mauiEmbedding) && platforms == wpf)"
"value": "(platforms == wpf)"
},
"useNonMauiPlatforms": {
"type": "computed",
"datatype": "bool",
"value": "(platforms == wpf || platforms == wasm || platforms == gtk || platforms == linux-fb || platforms == macos)"
},
"xamlNamespaces": {
"type": "generated",
"generator": "switch",
"replaces": "$xamlNamespaces$",
"parameters": {
"evaluator": "C++",
"datatype": "string",
"cases": [
{
// Can't use useNonMauiPlatforms here as we can't rely on computed values
"condition": "(mauiEmbedding && (platforms == wpf || platforms == wasm || platforms == gtk || platforms == linux-fb || platforms == macos))",
"value": "\n\txmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\n\txmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n\txmlns:maui=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n\txmlns:not_maui=\"http://notmaui\"\n\tmc:Ignorable=\"d not_maui\""
},
{
"condition": "!(mauiEmbedding && (platforms == wpf || platforms == wasm || platforms == gtk || platforms == linux-fb || platforms == macos))",
"value": "\n\txmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\n\txmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n\tmc:Ignorable=\"d\""
}
]
}
},
"useDataContracts": {
"type": "computed",
Expand Down Expand Up @@ -1105,7 +1130,7 @@
"useSkia": {
"type": "computed",
"datatype": "bool",
"value": "((!mauiEmbedding) && (platforms == wpf || platforms == gtk || platforms == linux-fb))"
"value": "(platforms == wpf || platforms == gtk || platforms == linux-fb)"
},
"useServer": {
"type": "computed",
Expand Down
17 changes: 15 additions & 2 deletions src/Uno.Templates/content/unoapp/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<!--#endif-->

<NoWarn>$(NoWarn);CA1416;NU1507</NoWarn>
<!--#if (mauiEmbedding)-->
<!--
Adding NoWarn to remove build warnings
NU1507: Warning when there are multiple package sources when using CPM with no source mapping
NETSDK1023: Microsoft.Maui.Graphics reference required to avoid build error causes warning because it's already implicitly referenced by Maui SDK
-->
<NoWarn>$(NoWarn);NU1507;NETSDK1023</NoWarn>
<!--#else-->
<!--
Adding NoWarn to remove build warnings
NU1507: Warning when there are multiple package sources when using CPM with no source mapping
-->
<NoWarn>$(NoWarn);NU1507</NoWarn>
<!--#endif-->

<DefaultLanguage>en</DefaultLanguage>

Expand Down Expand Up @@ -70,7 +83,7 @@
<IsWinAppSdk>true</IsWinAppSdk>
<SupportedOSPlatformVersion>10.0.18362.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<EnableCoreMrtTooling Condition=" '$(BuildingInsideVisualStudio)' != 'true' ">false</EnableCoreMrtTooling>
</PropertyGroup>
</When>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,6 @@
<!--#if (useHttp)-->
<ProjectReference Include="..\MyExtensionsApp._1.DataContracts\MyExtensionsApp._1.DataContracts.csproj" />
<!--#endif-->
<!--#if (mauiEmbedding)-->
<ProjectReference Include="..\MyExtensionsApp._1.MauiControls\MyExtensionsApp._1.MauiControls.csproj" />
<!--#endif-->
</ItemGroup>
<Import Project="..\MyExtensionsApp._1.Base\base.props" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<RootNamespace>MyExtensionsApp._1.Windows</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
</PropertyGroup>
Expand Down Expand Up @@ -227,9 +227,6 @@
<!--#if (useHttp)-->
<ProjectReference Include="..\MyExtensionsApp._1.DataContracts\MyExtensionsApp._1.DataContracts.csproj" />
<!--#endif-->
<!--#if (mauiEmbedding)-->
<ProjectReference Include="..\MyExtensionsApp._1.MauiControls\MyExtensionsApp._1.MauiControls.csproj" />
<!--#endif-->
</ItemGroup>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>arm64</Platform>
<RuntimeIdentifier>win10-arm64</RuntimeIdentifier>
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x64</Platform>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x86</Platform>
<RuntimeIdentifier>win10-x86</RuntimeIdentifier>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)

//+:cnd:noEmit
#if mauiEmbedding
//-:cnd:noEmit
#if MAUI_EMBEDDING
this.UseMauiEmbedding<MauiControls.App>(MainWindow, maui => maui
.UseMauiControls());
#endif
//+:cnd:noEmit
#endif
//-:cnd:noEmit

// Do not repeat app initialization when the Window already has content,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ protected async override void OnLaunched(LaunchActivatedEventArgs args)
// Add navigation support for toolkit controls such as TabBar and NavigationView
.UseToolkitNavigation()
#endif
//+:cnd:noEmit
#if mauiEmbedding
//-:cnd:noEmit
#if MAUI_EMBEDDING
.UseMauiEmbedding<MauiControls.App>(maui => maui
.UseMauiControls())
#endif
//+:cnd:noEmit
#endif
//-:cnd:noEmit
.Configure(host => host
#if DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@
global using MyExtensionsApp._1.Services.Endpoints;
#endif
#if (mauiEmbedding)
//-:cnd:noEmit
#if MAUI_EMBEDDING
global using MyExtensionsApp._1.MauiControls;
#endif
//+:cnd:noEmit
#endif
#if (useCsharpMarkup)
global using Uno.Extensions.Markup;
#if (useMaterial)
Expand Down
20 changes: 15 additions & 5 deletions src/Uno.Templates/content/unoapp/MyExtensionsApp._1/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
<Page x:Class="MyExtensionsApp._1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyExtensionsApp._1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:local="using:MyExtensionsApp._1"$xamlNamespaces$
Background="{ThemeResource $themeBackgroundBrush$}">

<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock AutomationProperties.AutomationId="HelloTextBlock"
Text="Hello Uno Platform"
HorizontalAlignment="Center" />
<!--#if (mauiEmbedding)-->
<!--#if (useNonMauiPlatforms)-->
<maui:Grid>
<embed:MauiHost x:Name="MauiHostElement"
xmlns:embed="using:Uno.Extensions.Maui"
xmlns:controls="using:MyExtensionsApp._1.MauiControls"
Source="controls:EmbeddedControl" />
</maui:Grid>
<not_maui:Grid>
<TextBlock AutomationProperties.AutomationId="NotMauiTextBlock"
Text="Alternative content for Non-Maui targets"
HorizontalAlignment="Center" />
</not_maui:Grid>
<!--#else-->
<embed:MauiHost x:Name="MauiHostElement"
xmlns:embed="using:Uno.Extensions.Maui"
xmlns:controls="using:MyExtensionsApp._1.MauiControls"
Source="controls:EmbeddedControl" />
<!--#endif-->
<!--#endif-->
</StackPanel>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,6 @@
must be the highest found in https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref.
-->
<!-- <WindowsSdkPackageVersion>10.0.22621.28</WindowsSdkPackageVersion> -->
<!--#if (useMsalAuthentication)-->
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<!--#endif-->
</PropertyGroup>
<!--#if (!mauiEmbedding)-->
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<Page x:Class="MyExtensionsApp._1.Presentation.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyExtensionsApp._1.Presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:local="using:MyExtensionsApp._1.Presentation"$xamlNamespaces$
xmlns:uen="using:Uno.Extensions.Navigation.UI"$toolkitNamespace$
NavigationCacheMode="Required"
Background="{ThemeResource $themeBackgroundBrush$}">
Expand All @@ -25,10 +22,24 @@
VerticalAlignment="Center"
Spacing="16">
<!--#if (mauiEmbedding)-->
<!--#if (useNonMauiPlatforms)-->
<maui:Grid>
<embed:MauiHost x:Name="MauiHostElement"
xmlns:embed="using:Uno.Extensions.Maui"
xmlns:controls="using:MyExtensionsApp._1.MauiControls"
Source="controls:EmbeddedControl" />
</maui:Grid>
<not_maui:Grid>
<TextBlock AutomationProperties.AutomationId="NotMauiTextBlock"
Text="Alternative content for Non-Maui targets"
HorizontalAlignment="Center" />
</not_maui:Grid>
<!--#else-->
<embed:MauiHost x:Name="MauiHostElement"
xmlns:embed="using:Uno.Extensions.Maui"
xmlns:controls="using:MyExtensionsApp._1.MauiControls"
Source="controls:EmbeddedControl" />
xmlns:embed="using:Uno.Extensions.Maui"
xmlns:controls="using:MyExtensionsApp._1.MauiControls"
Source="controls:EmbeddedControl" />
<!--#endif-->
<!--#endif-->
<TextBox Text="{Binding Name, Mode=TwoWay}"
PlaceholderText="Enter your name:" />
Expand Down

0 comments on commit e9f401b

Please sign in to comment.