Microsoft.PowerShell.SDK doesn't work in a AspNetCore Blazor WebAssembly project #13755
Comments
|
Could you test with Microsoft.PowerShell.SDK 7.1 RC1? |
|
@iSazonov In april, I put a demo on twitter of a working prototype on Mono.Wasm/PowerShell 7 hosted on Github Pages. I will submit a working PR soon for net5.0 RC1, but there is a lot of subjects like fileless (on startup, help system, module), trimming, preprocessor, async, sdk etc... Wasm is an embedded stack so most of the time, it's not a question, it's a behaviour : the minimal path/size/features. For example, the PowerShell master repo is not well compatible with this kind of restriction : You can try on my previous github page demo :
I will use this issue as a home to publish technical informations and read community's suggestions. |
Why there is no TFM for WebAssembly
New patternsguard the call :
mark the member as being unsupported :
You have to explicitly indicate that you intend to support your project in Blazor Web Assembly by adding the item to your project file:
Microsoft.NetCore.App APIs unsupported by Blazor WebAssemblyEntire assemblies :
Partial / Limited / Restrictions :
Source : |
General Trimming Options
Framework Feature Switches
source : |
|
@SteveL-MSFT I will need some advices/directions about LogProvider. It's maybe a good candidat for your plugin system ? PowerShell/src/System.Management.Automation/utils/tracing/PSEtwLog.cs Lines 13 to 31 in 16cc9aa Temporary Workaround
|
We could think about |
With a dependency injection system or by adding an internal static property Provider to PSEtwLog ? @iSazonov About trimming, I know it's an area than interest you, I need a script to benchmark size/performance/GC of each MSBuild Property (there is too much properties, I need raw data to choose). Do you know if something already exists ? I will have a look of DotNetBenchmark. |
We have no need to use DI. I guess it will be simple custom implementation of the ILogger.
|
|
After reading how works this plugin system DotNetCorePlugins, I'm afraid that the compatibility with Wasm will be an extra cost to implement. FI, this is a sample for lazy load assemblies in wasm (through the router and url browsing).
source : Lazy load assemblies in ASP.NET Core Blazor WebAssembly About ILogger, I will continue for Blazor to use Console.WriteLine inside SMA Logger code until the new logger will be available. There is only one destination to ILogger and Console : the browser console, the difference is only about formatting, so it doesn't matter now. |
|
For browser scenario, it seems that logging should just be disabled as it's not obvious to me where the logs would go to be something you can inspect later. Sending it to the console (which presumably would show up in output) might be ok for development purposes, but not general usage. |
|
That just tells me that we need to have a pluggable logging destination, then. It not being obvious is a reason to leave it to the person implementing it in nonstandard scenarios, not disabling it entirely. |
|
On logging, here's the "best practice" apparently: https://docs.microsoft.com/en-us/aspnet/core/blazor/fundamentals/logging?view=aspnetcore-3.1#blazor-webassembly
|
|
Microsoft.Extensions.* are the librairies from aspnetcore team, but starting net5.0, they are splitted into runtime and aspnetcore We need a layer with ILogger, and a way to specify an already ILogger to SMA in App Mode (through InitialSessionState ?). The only one logger extension for Blazor is BlazorExtensions.Logging. It's an interesting Logger because it implements the JS API Console.Table. @SteveL-MSFT AspNetCore use the logger to write error in the console (developper tools) like Javascript. To debug the C# code, we use the Browser debugger, it's very weird, you trace C# powershell source inside the browser tools. More informations here : Blazor Client Side Debugging
|
|
Working :
Not Working : Update Help + Web Cmdlets + More
|
|
There is some work going on in OmniSharp/csharp-language-server-protocol#456 to allow the library that we use in PowerShellEditorServices to work in Blazor WASM. With that work + work to PowerShell to get it working in Blazor WASM, we can create a PowerShell editing experience that's entirely in the browser like what the Bicep team did here: https://bicepdemo.z22.web.core.windows.net/experiment/lsp/index.html |
|
@TylerLeonhardt Nice ! I started a new job, and we are confined in Paris. I will try to make an update the next week. |
|
@TylerLeonhardt that Bicep POC is really inspiring! Thanks for sharing. |
transferred from dotnet/aspnetcore#25844
When using the preview of AspNetCore Blazor WebAssembly and attempting to utilize the Microsoft.PowerShell.SDK package, Blazor WebAssembly is unable to load the System.Management.Automation.dll
Steps to reproduce
Microsoft.PowerShell.SDKpackage referencePowerShellhost Example repoExpected behavior
it works
Actual behavior
Exceptions:
Environment data
The text was updated successfully, but these errors were encountered: