Skip to content

Commit

Permalink
Merge pull request #90 from egvijayanand/working
Browse files Browse the repository at this point in the history
Embedded project updated to .NET 9 Preview 7
  • Loading branch information
egvijayanand authored Aug 26, 2024
2 parents e8966e0 + 5f0bace commit 184c909
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 90 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sdk": {
"allowPrerelease": true,
"rollForward": "latestMinor",
"version": "7.0.100"
"version": "8.0.100"
}
}
1 change: 1 addition & 0 deletions src/NET_8/global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"sdk": {
"allowPrerelease": true,
"rollForward": "latestMinor",
"version": "8.0.100"
}
Expand Down
44 changes: 20 additions & 24 deletions src/NET_9/EmbeddedWindows/EmbeddedWindows/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
namespace EmbeddedWindows
namespace EmbeddedWindows;

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : Application
{
private Window? m_window;

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
}
public App() => this.InitializeComponent();

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
m_window?.Activate();
}

private Window? m_window;
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
m_window?.Activate();
}
}
14 changes: 9 additions & 5 deletions src/NET_9/EmbeddedWindows/EmbeddedWindows/EmbeddedWindows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<EnableMsixTooling>true</EnableMsixTooling>
<WindowsPackageType>None</WindowsPackageType>

<!-- .NET MAUI -->
<UseMaui>true</UseMaui>
<MauiEnablePlatformUsings>true</MauiEnablePlatformUsings>

<!-- Project Options -->
<Nullable>enable</Nullable>
<!--<ImplicitUsings>enable</ImplicitUsings>-->
Expand All @@ -20,8 +24,9 @@
<UseRidGraph>true</UseRidGraph>
<Platforms>x86;x64;arm64</Platforms>
<ApplicationManifest>app.manifest</ApplicationManifest>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 8">win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
</PropertyGroup>

<ItemGroup>
Expand All @@ -37,10 +42,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.0-preview.1.9973" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.0-preview.1.9973" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.*" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.*" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.*" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>arm64</Platform>
<RuntimeIdentifier>win10-arm64</RuntimeIdentifier>
<Platform>ARM64</Platform>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">win-arm64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 8">win10-arm64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
<!--
See https://github.com/microsoft/CsWinRT/issues/373
<PublishTrimmed>True</PublishTrimmed>
-->
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x64</Platform>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 8">win10-x64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
<!--
See https://github.com/microsoft/CsWinRT/issues/373
<PublishTrimmed>True</PublishTrimmed>
-->
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x86</Platform>
<RuntimeIdentifier>win10-x86</RuntimeIdentifier>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">win-x86</RuntimeIdentifier>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 8">win10-x86</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
<!--
See https://github.com/microsoft/CsWinRT/issues/373
<PublishTrimmed>True</PublishTrimmed>
-->
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"profiles": {
"EmbeddedWindows (Package)": {
"commandName": "MsixPackage"
},
"EmbeddedWindows (Unpackaged)": {
"Windows Machine": {
"commandName": "Project"
}
}
Expand Down
54 changes: 32 additions & 22 deletions src/NET_9/EmbeddedWindows/EmbeddedWindows/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Platform;
using Microsoft.Maui;
using Microsoft.Maui.Embedding;
using Microsoft.Extensions.DependencyInjection;
// Note: There's a change in namespace.
using Microsoft.Maui.Controls.Embedding;
//using Microsoft.Maui.Embedding;

namespace EmbeddedWindows
namespace EmbeddedWindows;

/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainWindow : Window
{
/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainWindow : Window
public MainWindow()
{
public MainWindow()
{
this.InitializeComponent();
this.InitializeComponent();

var mauiApp = MauiApp.CreateBuilder()
.UseMauiEmbeddedApp<MyApp>() // Note: The method name too got updated.
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OS400");
fonts.AddFont("OpenSans-SemiBold.ttf", "OS600");
})
.Build();

// From .NET MAUI 9 Preview 7 onwards, the below method call is no longer required
// as the .NET MAUI Embedding process is revamped.
// While doing .NET MAUI Embedding, this call is required so that
// the Application object instance gets resolved.
//var _ = mauiApp.Services.GetRequiredService<IApplication>();

var mauiContext = new MauiContext(mauiApp.Services);

var mauiApp = MauiApp.CreateBuilder()
.UseMauiEmbedding<MyApp>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OS400");
fonts.AddFont("OpenSans-SemiBold.ttf", "OS600");
})
.Build();
// While doing .NET MAUI Embedding, this call is required so that the Application object instance gets resolved.
var _ = mauiApp.Services.GetRequiredService<IApplication>();
Content = new MauiPage().ToPlatform(new MauiContext(mauiApp.Services));
}
// Platform-neutral - Windowless API
Content = new MauiPage().ToPlatform(mauiContext);
// Updated Window inclusive API
Content = new MauiPage().ToPlatformEmbedded(mauiContext);
}
}
1 change: 0 additions & 1 deletion src/NET_9/EmbeddedWindows/MauiLib/MauiLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/NET_9/EmbeddedWindows/MauiLib/MauiPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Grid>
<Label
HorizontalOptions="Center"
Text=".NET MAUI Embedding is cool!!!"
Text=".NET MAUI Embedding is uber cool!!!"
VerticalOptions="Center" />
</Grid>
</ContentPage.Content>
Expand Down
12 changes: 4 additions & 8 deletions src/NET_9/EmbeddedWindows/MauiLib/MauiPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
namespace MauiLib
namespace MauiLib;

public partial class MauiPage : ContentPage
{
public partial class MauiPage : ContentPage
{
public MauiPage()
{
InitializeComponent();
}
}
public MauiPage() => InitializeComponent();
}
12 changes: 4 additions & 8 deletions src/NET_9/EmbeddedWindows/MauiLib/MyApp.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
namespace MauiLib
namespace MauiLib;

public partial class MyApp : Application
{
public partial class MyApp : Application
{
public MyApp()
{
InitializeComponent();
}
}
public MyApp() => InitializeComponent();
}

0 comments on commit 184c909

Please sign in to comment.