From 1d447caa8ead90a751942224cb6634a4498263d9 Mon Sep 17 00:00:00 2001 From: Jerome Laban <jerome.laban@nventive.com> Date: Thu, 16 Sep 2021 16:35:11 -0400 Subject: [PATCH 1/3] fix: restore net6.0 for WebAssembly, disable linker in debug --- .../Wasm/UnoQuickStart.Wasm.csproj | 8 +++++++- .../UnoSolutionTemplate/Wasm/UnoQuickStart.Wasm.csproj | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/SolutionTemplate/UnoSolutionTemplate.net6/Wasm/UnoQuickStart.Wasm.csproj b/src/SolutionTemplate/UnoSolutionTemplate.net6/Wasm/UnoQuickStart.Wasm.csproj index 44dd0ac0edcf..81df2f5ad1fd 100644 --- a/src/SolutionTemplate/UnoSolutionTemplate.net6/Wasm/UnoQuickStart.Wasm.csproj +++ b/src/SolutionTemplate/UnoSolutionTemplate.net6/Wasm/UnoQuickStart.Wasm.csproj @@ -2,7 +2,7 @@ <PropertyGroup> <OutputType>Exe</OutputType> - <TargetFramework>net5.0</TargetFramework> + <TargetFramework>net6.0</TargetFramework> <NoWarn>NU1701</NoWarn> </PropertyGroup> @@ -11,6 +11,12 @@ <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> <ItemGroup> diff --git a/src/SolutionTemplate/UnoSolutionTemplate/Wasm/UnoQuickStart.Wasm.csproj b/src/SolutionTemplate/UnoSolutionTemplate/Wasm/UnoQuickStart.Wasm.csproj index a74fba5d6890..de6a623196a7 100644 --- a/src/SolutionTemplate/UnoSolutionTemplate/Wasm/UnoQuickStart.Wasm.csproj +++ b/src/SolutionTemplate/UnoSolutionTemplate/Wasm/UnoQuickStart.Wasm.csproj @@ -11,6 +11,12 @@ <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> <ItemGroup> @@ -48,8 +54,8 @@ <PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.0.1" /> <PackageReference Include="Uno.UI.WebAssembly" Version="2.2.0" /> <PackageReference Include="Uno.UI.RemoteControl" Version="2.2.0" Condition="'$(Configuration)'=='Debug'" /> - <PackageReference Include="Uno.Wasm.Bootstrap" Version="2.1.0" /> - <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="2.1.0" /> + <PackageReference Include="Uno.Wasm.Bootstrap" Version="3.0.0" /> + <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="3.0.0" /> </ItemGroup> <Import Project="..\$ext_safeprojectname$.Shared\$ext_safeprojectname$.Shared.projitems" Label="Shared" Condition="Exists('..\$ext_safeprojectname$.Shared\$ext_safeprojectname$.Shared.projitems')" /> From 4dd67f4e1c56ee7266adf55222f98f8daccc9651 Mon Sep 17 00:00:00 2001 From: Jerome Laban <jerome.laban@nventive.com> Date: Thu, 16 Sep 2021 22:28:14 -0400 Subject: [PATCH 2/3] docs: Update WebAssembly debugging documentation --- doc/articles/debugging-wasm.md | 41 +++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/doc/articles/debugging-wasm.md b/doc/articles/debugging-wasm.md index cc974fb2e115..9837c114f436 100644 --- a/doc/articles/debugging-wasm.md +++ b/doc/articles/debugging-wasm.md @@ -1,19 +1,38 @@ # Using the WebAssembly C# Debugger -Debugging WebAssembly via Google Chrome is experimentally supported by the Uno Platform. We HIGHLY recommend that you use [Google Chrome Canary](https://www.google.com/chrome/canary/). Step-through debugging (in, out, over), breakpoints, inspection of run-time locals and viewing .NET source code from the developer tools works. Additional capabilities and browser support will become available as Microsoft adds [support for them to mono](https://github.com/mono/mono/tree/master/sdks/wasm). +There are two ways to debug a WebAssembly application: +- Using Visual Studio 2019 or 2022 integrated debugger (preferred) +- Using the browser's debugger -- Make your WASM project the startup project (right-click **set as startup** in Solution Explorer) -- Make sure you have the following lines defined in your project file which enable the Mono runtime debugger. Please ensure that `DEBUG` constant is defined and debug symbols are emitted and are of the type `portable`: +## Using Visual Studio +Here’s what you need to do to debug an Uno application in Visual Studio (2019 16.10+ or 2022 17.0 Preview 3.1+): + +- Install the latest [Uno Platform Visual Studio templates](https://marketplace.visualstudio.com/items?itemName=nventivecorp.uno-platform-addin) +- Have Chrome or Edge (Chromium based) +- In the Nuget Package manager, update `Uno.Wasm.Bootstrap` and `Uno.Wasm.Bootstrap.DevServer` 3.0.0 or later +- Ensure that `<MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>` is set in your csproj +- Ensure that in the `Properties/launchSettings.json` file, the following like below each `launchBrowser` line: + ```json + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + ``` + +Then you can start debugging with the VS debugger toolbar: + - Select **IIS Express** or your application name as the debugging target + - Select **Chrome** as the Web Browser + - Press <kbd>F5</kbd> or _Debug_ > _Start Debugging_ -```xml -<PropertyGroup Condition="'$(Configuration)'=='Debug'"> - <MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled> - <DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants> - <DebugType>portable</DebugType> - <DebugSymbols>true</DebugSymbols> -</PropertyGroup> -``` +You should now be able to set breakpoints or do step by step debugging of your code. +### Tips for debugging in visual studio +- Some debugger features may not have yet been implemented by the .NET and Visual Studio team. You can take a look the [dotnet/runtime](https://github.com/dotnet/runtime) repository for more details. +- If the breaking do not hit, make sure that the `inspecturi` lines have been added to the `Properties/launchSettings.json` file. + +## Using the browser debugger + +To debug your application: +- Make your WASM project the startup project (right-click **set as startup** in Solution Explorer) +- In the Nuget Package manager, update `Uno.Wasm.Bootstrap` and `Uno.Wasm.Bootstrap.DevServer` 3.0.0 or later +- Ensure that `<MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>` is set in your csproj - In the debugging toolbar: - Select **IIS Express** as the debugging target From 3def6eedad338ef31a9db57dcb54310a1da56f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Laban?= <jerome.laban@nventive.com> Date: Fri, 17 Sep 2021 08:46:17 -0400 Subject: [PATCH 3/3] docs: Adjust wasm debugger instructions Co-authored-by: Youssef Victor <youssefvictor00@gmail.com> --- doc/articles/debugging-wasm.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/articles/debugging-wasm.md b/doc/articles/debugging-wasm.md index 9837c114f436..f99c50596ead 100644 --- a/doc/articles/debugging-wasm.md +++ b/doc/articles/debugging-wasm.md @@ -9,7 +9,7 @@ Here’s what you need to do to debug an Uno application in Visual Studio (2019 - Install the latest [Uno Platform Visual Studio templates](https://marketplace.visualstudio.com/items?itemName=nventivecorp.uno-platform-addin) - Have Chrome or Edge (Chromium based) -- In the Nuget Package manager, update `Uno.Wasm.Bootstrap` and `Uno.Wasm.Bootstrap.DevServer` 3.0.0 or later +- In the NuGet Package Manager, update `Uno.Wasm.Bootstrap` and `Uno.Wasm.Bootstrap.DevServer` 3.0.0 or later - Ensure that `<MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>` is set in your csproj - Ensure that in the `Properties/launchSettings.json` file, the following like below each `launchBrowser` line: ```json @@ -31,7 +31,7 @@ You should now be able to set breakpoints or do step by step debugging of your c To debug your application: - Make your WASM project the startup project (right-click **set as startup** in Solution Explorer) -- In the Nuget Package manager, update `Uno.Wasm.Bootstrap` and `Uno.Wasm.Bootstrap.DevServer` 3.0.0 or later +- In the NuGet Package Manager, update `Uno.Wasm.Bootstrap` and `Uno.Wasm.Bootstrap.DevServer` to 3.0.0 or later - Ensure that `<MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>` is set in your csproj - In the debugging toolbar: