Skip to content

Commit

Permalink
chore: Fixing build and debugging for wasm/gtk
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrandolph committed Nov 13, 2023
1 parent df46af5 commit fa660d4
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 156 deletions.
2 changes: 1 addition & 1 deletion samples/MauiEmbedding/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageVersion Include="Telerik.UI.for.Maui" Version="5.1.0" Condition="$(_UseTelerik)" />
<PackageVersion Include="Esri.ArcGISRuntime.Maui" Version="200.1.0" />
<PackageVersion Include="Microsoft.Windows.Compatibility" Version="7.0.4" />
<PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.4.0" />
<PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.7.0" />
<PackageVersion Include="Uno.WinUI.WebAssembly" Version="5.0.19" />
<PackageVersion Include="Uno.Wasm.Bootstrap" Version="7.0.27" />
<PackageVersion Include="Uno.Wasm.Bootstrap.DevServer" Version="7.0.27" />
Expand Down
4 changes: 2 additions & 2 deletions samples/Playground/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
<PackageVersion Include="Uno.Core" Version="4.0.1" />
<PackageVersion Include="Uno.Core.Extensions.Logging.Singleton" Version="4.0.1" />
<PackageVersion Include="Uno.Extensions.Logging.OSLog " Version="1.7.0" />
<PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.3.0" />
<PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.7.0" />
<PackageVersion Include="Uno.Material" Version="4.0.4" />
<PackageVersion Include="Uno.Material.WinUI" Version="4.0.4" />
<PackageVersion Include="Uno.Toolkit.WinUI" Version="5.0.15" />
<PackageVersion Include="Uno.Toolkit.WinUI.Material" Version="5.0.15" />
<PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="5.0.15" />
<PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="5.0.19" />
<PackageVersion Include="Uno.UniversalImageLoader" Version="1.9.36" />
<PackageVersion Include="Uno.Wasm.Bootstrap" Version="7.0.20" />
<PackageVersion Include="Uno.Wasm.Bootstrap.DevServer" Version="7.0.20" />
Expand Down
17 changes: 17 additions & 0 deletions samples/Playground/FixExtensionLibs.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project ToolsVersion="15.0">
<Target Name="FixPlaygroundReferences" BeforeTargets="BuildDist">
<ItemGroup>
<PlaygroundPaths Include="@(ReferenceCopyLocalPaths)" Condition="'%(FileName)%(Extension)'=='Playground.dll'" />
</ItemGroup>
<PropertyGroup>
<PlaygroundLibs>%(PlaygroundPaths.RootDir)%(PlaygroundPaths.Directory)*.WinUI.dll</PlaygroundLibs>
</PropertyGroup>
<ItemGroup>
<FilesToDelete Include="$(PlaygroundLibs)"/>
</ItemGroup>
<Delete Files="@(FilesToDelete)" >
<Output TaskParameter="DeletedFiles" ItemName="DeletedList"/>
</Delete>
<Message Text="Deleted files: '@(DeletedList)'"/>
</Target>
</Project>
140 changes: 70 additions & 70 deletions samples/Playground/Playground.Base/AppHead.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace Playground;

public sealed partial class AppHead : App
{
static AppHead() =>
InitializeLogging();
//static AppHead() =>
// InitializeLogging();

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
Expand All @@ -31,72 +31,72 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
Window.SetWindowIcon();
}

/// <summary>
/// Configures global Uno Platform logging
/// </summary>
private static void InitializeLogging()
{
#if DEBUG
// Logging is disabled by default for release builds, as it incurs a significant
// initialization cost from Microsoft.Extensions.Logging setup. If startup performance
// is a concern for your application, keep this disabled. If you're running on the web or
// desktop targets, you can use URL or command line parameters to enable it.
//
// For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html

var factory = LoggerFactory.Create(builder =>
{
#if __WASM__
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
#elif __IOS__ || __MACCATALYST__
builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider());
#elif NETFX_CORE
builder.AddDebug();
#else
builder.AddConsole();
#endif

// Exclude logs below this level
builder.SetMinimumLevel(LogLevel.Information);

// Default filters for Uno Platform namespaces
builder.AddFilter("Uno", LogLevel.Warning);
builder.AddFilter("Windows", LogLevel.Warning);
builder.AddFilter("Microsoft", LogLevel.Warning);

// Generic Xaml events
// builder.AddFilter("Microsoft.UI.Xaml", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.VisualStateGroup", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.StateTriggerBase", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.UIElement", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.FrameworkElement", LogLevel.Trace );

// Layouter specific messages
// builder.AddFilter("Microsoft.UI.Xaml.Controls", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.Controls.Layouter", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.Controls.Panel", LogLevel.Debug );

// builder.AddFilter("Windows.Storage", LogLevel.Debug );

// Binding related messages
// builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );

// Binder memory references tracking
// builder.AddFilter("Uno.UI.DataBinding.BinderReferenceHolder", LogLevel.Debug );

// DevServer and HotReload related
// builder.AddFilter("Uno.UI.RemoteControl", LogLevel.Information);

// Debug JS interop
// builder.AddFilter("Uno.Foundation.WebAssemblyRuntime", LogLevel.Debug );
});

global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = factory;

#if HAS_UNO
global::Uno.UI.Adapter.Microsoft.Extensions.Logging.LoggingAdapter.Initialize();
#endif
#endif
}
// /// <summary>
// /// Configures global Uno Platform logging
// /// </summary>
// private static void InitializeLogging()
// {
//#if DEBUG
// // Logging is disabled by default for release builds, as it incurs a significant
// // initialization cost from Microsoft.Extensions.Logging setup. If startup performance
// // is a concern for your application, keep this disabled. If you're running on the web or
// // desktop targets, you can use URL or command line parameters to enable it.
// //
// // For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html

// var factory = LoggerFactory.Create(builder =>
// {
//#if __WASM__
// builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
//#elif __IOS__ || __MACCATALYST__
// builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider());
//#elif NETFX_CORE
// builder.AddDebug();
//#else
// builder.AddConsole();
//#endif

// // Exclude logs below this level
// builder.SetMinimumLevel(LogLevel.Information);

// // Default filters for Uno Platform namespaces
// builder.AddFilter("Uno", LogLevel.Warning);
// builder.AddFilter("Windows", LogLevel.Warning);
// builder.AddFilter("Microsoft", LogLevel.Warning);

// // Generic Xaml events
// // builder.AddFilter("Microsoft.UI.Xaml", LogLevel.Debug );
// // builder.AddFilter("Microsoft.UI.Xaml.VisualStateGroup", LogLevel.Debug );
// // builder.AddFilter("Microsoft.UI.Xaml.StateTriggerBase", LogLevel.Debug );
// // builder.AddFilter("Microsoft.UI.Xaml.UIElement", LogLevel.Debug );
// // builder.AddFilter("Microsoft.UI.Xaml.FrameworkElement", LogLevel.Trace );

// // Layouter specific messages
// // builder.AddFilter("Microsoft.UI.Xaml.Controls", LogLevel.Debug );
// // builder.AddFilter("Microsoft.UI.Xaml.Controls.Layouter", LogLevel.Debug );
// // builder.AddFilter("Microsoft.UI.Xaml.Controls.Panel", LogLevel.Debug );

// // builder.AddFilter("Windows.Storage", LogLevel.Debug );

// // Binding related messages
// // builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );
// // builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );

// // Binder memory references tracking
// // builder.AddFilter("Uno.UI.DataBinding.BinderReferenceHolder", LogLevel.Debug );

// // DevServer and HotReload related
// // builder.AddFilter("Uno.UI.RemoteControl", LogLevel.Information);

// // Debug JS interop
// // builder.AddFilter("Uno.Foundation.WebAssemblyRuntime", LogLevel.Debug );
// });

// global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = factory;

//#if HAS_UNO
// global::Uno.UI.Adapter.Microsoft.Extensions.Logging.LoggingAdapter.Initialize();
//#endif
//#endif
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@
<!--<PackageReference Include="Uno.WinUI.DevServer" Condition="'$(Configuration)'=='Debug'" />-->
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" />
</ItemGroup>
<ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Playground\Playground.csproj" />
</ItemGroup>

<ProjectReference Include="..\..\..\src\Uno.Extensions.Hosting.UI\Uno.Extensions.Hosting.WinUI.Skia.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Logging\Uno.Extensions.Logging.WinUI.Skia.csproj" />
</ItemGroup>

<Import Project="..\Playground.Base\base.props" />

<Import Project="..\FixExtensionLibs.targets" />
</Project>
121 changes: 63 additions & 58 deletions samples/Playground/Playground.Wasm/Playground.Wasm.csproj
Original file line number Diff line number Diff line change
@@ -1,71 +1,76 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<NoWarn>$(NoWarn);NU1504;NU1505;NU1701</NoWarn>
<!-- Disabled due to issue with Central Package Management with implicit using -->
<ImplicitUsings>disable</ImplicitUsings>
<WasmPWAManifestFile>manifest.webmanifest</WasmPWAManifestFile>
<AppDesignerFolder>Properties</AppDesignerFolder>
<!--
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<NoWarn>$(NoWarn);NU1504;NU1505;NU1701</NoWarn>
<!-- Disabled due to issue with Central Package Management with implicit using -->
<ImplicitUsings>disable</ImplicitUsings>
<WasmPWAManifestFile>manifest.webmanifest</WasmPWAManifestFile>
<AppDesignerFolder>Properties</AppDesignerFolder>
<!--
Supports Deep Linking Routes
https://aka.platform.uno/wasm-deeplink
-->
<WasmShellWebAppBasePath>/</WasmShellWebAppBasePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<!--
<WasmShellWebAppBasePath>/</WasmShellWebAppBasePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<!--
IL Linking is disabled in Debug configuration.
When building in Release, see https://platform.uno/docs/articles/features/using-il-linker-WebAssembly.html
-->
<WasmShellILLinkerEnabled>false</WasmShellILLinkerEnabled>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<!-- XAML Resource trimming https://aka.platform.uno/xaml-trimming -->
<!--<UnoXamlResourcesTrimming>true</UnoXamlResourcesTrimming>-->
<!-- Improve performance with AOT builds https://aka.platform.uno/wasm-aot -->
<!-- <WasmShellMonoRuntimeExecutionMode>InterpreterAndAOT</WasmShellMonoRuntimeExecutionMode> -->
<!-- Temporarily uncomment to generate an AOT profile https://aka.platform.uno/wasm-aot-profile -->
<!-- <WasmShellGenerateAOTProfile>true</WasmShellGenerateAOTProfile> -->
</PropertyGroup>
<ItemGroup>
<Content Include="manifest.webmanifest" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="WasmCSS\Fonts.css" />
<EmbeddedResource Include="WasmScripts\AppManifest.js" />
</ItemGroup>
<ItemGroup>
<LinkerDescriptor Include="LinkerConfig.xml" />
</ItemGroup>
<ItemGroup>
<!--
<WasmShellILLinkerEnabled>false</WasmShellILLinkerEnabled>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<!-- XAML Resource trimming https://aka.platform.uno/xaml-trimming -->
<!--<UnoXamlResourcesTrimming>true</UnoXamlResourcesTrimming>-->
<!-- Improve performance with AOT builds https://aka.platform.uno/wasm-aot -->
<!-- <WasmShellMonoRuntimeExecutionMode>InterpreterAndAOT</WasmShellMonoRuntimeExecutionMode> -->
<!-- Temporarily uncomment to generate an AOT profile https://aka.platform.uno/wasm-aot-profile -->
<!-- <WasmShellGenerateAOTProfile>true</WasmShellGenerateAOTProfile> -->
</PropertyGroup>
<ItemGroup>
<Content Include="manifest.webmanifest" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="WasmCSS\Fonts.css" />
<EmbeddedResource Include="WasmScripts\AppManifest.js" />
</ItemGroup>
<ItemGroup>
<LinkerDescriptor Include="LinkerConfig.xml" />
</ItemGroup>
<ItemGroup>
<!--
This item group is required by the project template because of the
new SDK-Style project, otherwise some files are not added automatically.
You can safely remove this ItemGroup completely.
-->
<None Include="Program.cs" />
<None Include="LinkerConfig.xml" />
<None Include="wwwroot\web.config" />
</ItemGroup>
<None Include="Program.cs" />
<None Include="LinkerConfig.xml" />
<None Include="wwwroot\web.config" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.Compatibility" />
<PackageReference Include="Uno.Wasm.Bootstrap" />
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" />
<PackageReference Include="Uno.WinUI.WebAssembly" />
<PackageReference Include="Uno.WinUI.DevServer" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" />
<PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Playground\Playground.csproj" />
</ItemGroup>
<Import Project="..\Playground.Base\base.props" />
<ItemGroup>
<PackageReference Include="Microsoft.Windows.Compatibility" />
<PackageReference Include="Uno.Wasm.Bootstrap" />
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" />
<PackageReference Include="Uno.WinUI.WebAssembly" />
<PackageReference Include="Uno.WinUI.DevServer" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" />
<PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Playground\Playground.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Hosting.UI\Uno.Extensions.Hosting.WinUI.Wasm.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Logging\Uno.Extensions.Logging.WinUI.Wasm.csproj" />
</ItemGroup>

<Import Project="..\Playground.Base\base.props" />

<Import Project="..\FixExtensionLibs.targets" />
</Project>
3 changes: 2 additions & 1 deletion samples/Playground/Playground.sln
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Playground Items", "Playgro
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Directory.Packages.props = Directory.Packages.props
FixExtensionLibs.targets = FixExtensionLibs.targets
global.json = global.json
EndProjectSection
EndProject
Expand Down Expand Up @@ -3066,7 +3067,7 @@ Global
{B4F14C65-EC7C-4641-81A6-576BA122E8C2} = {A7450AE8-53E1-4AD2-8E3A-4BF626269DC0}
{3B441D41-F441-4A0D-87A2-EC5D124C3D59} = {FA19ECB8-E725-4AFB-9DF8-E387B7AD12CE}
{743182C8-6956-4182-A868-DF7003B82032} = {FA19ECB8-E725-4AFB-9DF8-E387B7AD12CE}
{77081268-55C2-46C4-9CD3-5AE4A72A2F56} = {9FDE6A95-7086-43A9-A909-74C2FE64B509}
{77081268-55C2-46C4-9CD3-5AE4A72A2F56} = {DD8F5097-D88A-403A-A20C-B22242F46A2D}
{13C1A52F-E012-4052-AC85-FEAC1E76EB13} = {9FDE6A95-7086-43A9-A909-74C2FE64B509}
{2B47D53E-045E-4C51-A5C8-6BC8A81599A4} = {DD8F5097-D88A-403A-A20C-B22242F46A2D}
EndGlobalSection
Expand Down
4 changes: 3 additions & 1 deletion samples/Playground/Playground/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public static IApplicationBuilder ConfigureApp(this IApplicationBuilder builder)
.UseEnvironment(Environments.Development)
#endif

// Add platform specific log providers
// Note: Logging disabled as it breaks Wasm for Playground because it loads the
// non-wasm version of Uno.Ext.Logging.WinUI which registers the console logger
// instead of the wasm console logger
.UseLogging(configure: (context, logBuilder) =>
{
var host = context.HostingEnvironment;
Expand Down
5 changes: 2 additions & 3 deletions samples/Playground/Playground/Playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,13 @@
<ItemGroup>
<ProjectReference Include="..\..\..\src\Uno.Extensions.Configuration\Uno.Extensions.Configuration.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Core\Uno.Extensions.Core.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Hosting.UI\Uno.Extensions.Hosting.WinUI.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Hosting.UI\Uno.Extensions.Hosting.WinUI.csproj" ExcludeAssets="all" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Hosting\Uno.Extensions.Hosting.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Http.Refit\Uno.Extensions.Http.Refit.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Http.UI\Uno.Extensions.Http.WinUI.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Http\Uno.Extensions.Http.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Localization.UI\Uno.Extensions.Localization.WinUI.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Logging.Serilog\Uno.Extensions.Logging.Serilog.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Logging\Uno.Extensions.Logging.WinUI.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Logging\Uno.Extensions.Logging.WinUI.csproj" ExcludeAssets="all" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Navigation.Toolkit\Uno.Extensions.Navigation.Toolkit.WinUI.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Navigation.UI\Uno.Extensions.Navigation.WinUI.csproj" />
<ProjectReference Include="..\..\..\src\Uno.Extensions.Navigation\Uno.Extensions.Navigation.csproj" />
Expand Down
Loading

0 comments on commit fa660d4

Please sign in to comment.