Detect missing components on windows that does not support WSLC (Reduce requirement on Microsoft.WSL.Containers)
Is your feature request related to a problem? Please describe.
I would like to bundle the NuGet package Microsoft.WSL.Containers in my program that may run on older Windows that does not support WSLC.
The purpose is to offer container functionality if available and if not the program will still work as today.
I would like to detect WSL compatibility even on unsupported versions of Windows.
Describe the solution you'd like
-
Reduce requirement to net8.0 (without -windows...) (or net10.0)
-
Add a new
ComponentFlag.Windows10or use an existing flag to indicate WSL is missing.//Running on unsupported Windows var missing = WslcService.GetMissingComponents(); missing == ComponentFlag.Windows10
Describe alternatives you've considered
Build a secondary exe with the target framework net10.0-windows10.0.26100.0 called from the main exe with target framework net10.0. Any operation will then require communication between the two processes.
Logs are required for review from WSL team
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1
The script will output the path of the log file once done.
If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues
Once completed please upload the output files to this GitHub issue.
See Collect WSL logs (recommended method).
If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.
/feature
Diagnostic information
Found '/feature', adding tag 'feature'
FWIW, sharing an approach that might be relevant here: wip, a C# Native AOT CLI wrapper around wslc.exe, avoids depending on Microsoft.WSL.Containers for this kind of detection.
It ships as a plain net10.0 app (no -windows suffix) and checks for WSL2/WSLC by shelling out rather than calling into the API:
- WSL2: run
wsl.exe --statusand check the exit code —WindowsEnvironment.cs - WSLC: probe
PATH/System32forwslc.exe/wslc—CommandResolver.cs
Since wsl.exe predates WSLC, this seems to degrade reasonably on Windows versions without WSLC support — the process is just not found, without needing a Windows-only target framework. Not sure it covers every case GetMissingComponents() would want, but it might be a useful data point if a non--windows-TFM path is worth supporting alongside the NuGet API.