Skip to content

Commit

Permalink
rename extension from xaml to mxaml for maui xaml files, to workaroud…
Browse files Browse the repository at this point in the history
… the ava source gen issue

AvaloniaUI#7 (comment)
  • Loading branch information
juwens committed Sep 8, 2023
1 parent 38d921d commit 157e066
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 115 deletions.
3 changes: 1 addition & 2 deletions Avalonia.Maui/Avalonia.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
<PackageReference Include="Avalonia.iOS" Version="$(AvaloniaVersion)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net7.0-windows'))">
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Win32" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Win32" Version="$(AvaloniaVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion MauiSampleApp/AvaloniaApp.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
xmlns:local="using:MauiSample"
x:Class="MauiSample.AvaloniaApp">
<Application.Styles>
<FluentTheme Mode="Light"/>
<!--<FluentTheme Mode="Light"/>-->
</Application.Styles>
</Application>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
85 changes: 49 additions & 36 deletions MauiSampleApp/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
using Avalonia;
using Avalonia.Maui;
using Avalonia.Maui.Controls;
using Avalonia.Maui.Handlers;
using MauiSample;

namespace MauiSampleApp
{
public static class MauiProgram
{
public static Microsoft.Maui.Hosting.MauiApp CreateMauiApp()
{
var builder = Microsoft.Maui.Hosting.MauiApp.CreateBuilder();

builder.UseMauiApp<MauiApp>();

builder.UseAvalonia<AvaloniaApp>(appBuilder =>
{
});

builder.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

builder.ConfigureMauiHandlers(handlers =>
{
#if ANDROID || IOS || WINDOWS
handlers.AddHandler(typeof(AvaloniaView), typeof(AvaloniaViewHandler));
#endif
});

return builder.Build();
}
}
using Avalonia;
using Avalonia.Maui;
using Avalonia.Maui.Controls;
using Avalonia.Maui.Handlers;
using MauiSample;
using System.Collections.Immutable;

[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/2021/maui", "Microsoft.Maui.Controls", AssemblyName = "Microsoft.Maui.Controls")]

namespace MauiSampleApp
{

public static class MauiProgram
{
private static object DoNotOptimiceAway = ImmutableArray.Create(

typeof(Microsoft.Maui.Controls.Shell),
typeof(Microsoft.Maui.Controls.ContentPage),
typeof(Microsoft.Maui.Controls.Application),
typeof(Microsoft.Maui.Controls.ResourceDictionary)
);


public static Microsoft.Maui.Hosting.MauiApp CreateMauiApp()
{
var builder = Microsoft.Maui.Hosting.MauiApp.CreateBuilder();

builder.UseMauiApp<MauiApp>();

builder.UseAvalonia<AvaloniaApp>(appBuilder =>
{
});

builder.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

builder.ConfigureMauiHandlers(handlers =>
{
#if ANDROID || IOS || WINDOWS
handlers.AddHandler(typeof(AvaloniaView), typeof(AvaloniaViewHandler));
#endif
});

return builder.Build();
}
}
}
175 changes: 99 additions & 76 deletions MauiSampleApp/MauiSampleApp.csproj
Original file line number Diff line number Diff line change
@@ -1,76 +1,99 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android; net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>MauiSampleApp</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>MauiSample</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.mauisample</ApplicationId>
<ApplicationIdGuid>EBE44A8A-128A-438D-80EF-1832A9474CB3</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>
<!--<WindowsPackageType Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">None</WindowsPackageType>-->
<!--<ApplicationManifest>Platforms\Windows\app.manifest</ApplicationManifest>-->
<DefaultLanguage>en</DefaultLanguage>
</PropertyGroup>

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

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Avalonia.Maui\Avalonia.Maui.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="MauiApp.xaml.cs">
<DependentUpon>MauiApp.xaml</DependentUpon>
</Compile>
<Compile Update="AvaloniaApp.axaml.cs">
<DependentUpon>AvaloniaApp.axaml</DependentUpon>
</Compile>
<Compile Update="Platforms\Windows\App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<MauiXaml Update="AvaloniaCompositionPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android; net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>MauiSampleApp</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>MauiSample</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.mauisample</ApplicationId>
<ApplicationIdGuid>EBE44A8A-128A-438D-80EF-1832A9474CB3</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>
<!--<WindowsPackageType Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">None</WindowsPackageType>-->
<!--<ApplicationManifest>Platforms\Windows\app.manifest</ApplicationManifest>-->
<DefaultLanguage>en</DefaultLanguage>
</PropertyGroup>

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

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<None Remove="AppShell.mxaml" />
<None Remove="AvaloniaCompositionPage.mxaml" />
<None Remove="MainPage.mxaml" />
<None Remove="MauiApp.mxaml" />
<None Remove="Resources\Styles\Colors.mxaml" />
<None Remove="Resources\Styles\Styles.mxaml" />
</ItemGroup>

<ItemGroup>
<MauiXaml Include="AppShell.mxaml" />
<MauiXaml Include="AvaloniaCompositionPage.mxaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Include="MainPage.mxaml" />
<MauiXaml Include="MauiApp.mxaml" />
<MauiXaml Include="Resources\Styles\Colors.mxaml" />
<MauiXaml Include="Resources\Styles\Styles.mxaml" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Avalonia.Maui\Avalonia.Maui.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="AppShell.mxaml.cs">
<DependentUpon>AppShell.mxaml</DependentUpon>
</Compile>
<Compile Update="AvaloniaCompositionPage.mxaml.cs">
<DependentUpon>AvaloniaCompositionPage.mxaml</DependentUpon>
</Compile>
<Compile Update="MainPagem.mxaml.cs">
<DependentUpon>MainPage.mxaml</DependentUpon>
</Compile>
<Compile Update="MauiApp.mxaml.cs">
<DependentUpon>MauiApp.mxaml</DependentUpon>
</Compile>
<Compile Update="AvaloniaApp.axaml.cs">
<DependentUpon>AvaloniaApp.axaml</DependentUpon>
</Compile>
<Compile Update="Platforms\Windows\App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
</ItemGroup>

</Project>
File renamed without changes.
File renamed without changes.

0 comments on commit 157e066

Please sign in to comment.