Skip to content

Added samples to the API#40930

Open
craigloewen-msft wants to merge 2 commits into
masterfrom
user/crloewen/wslc-api-samples
Open

Added samples to the API#40930
craigloewen-msft wants to merge 2 commits into
masterfrom
user/crloewen/wslc-api-samples

Conversation

@craigloewen-msft

Copy link
Copy Markdown
Member

Added 4 basic samples for the WSLC API that will be referenced in the WSL docs.

Copilot AI review requested due to automatic review settings June 26, 2026 21:36
@craigloewen-msft craigloewen-msft requested a review from a team as a code owner June 26, 2026 21:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a set of standalone samples under doc/samples/ demonstrating how to use the WSL Container API (Microsoft.WSL.Containers) from C, C++/WinRT, and C#—intended to be referenced from WSL documentation.

Changes:

  • Adds three runnable “pull/run” samples: C (HelloWorld), C++/WinRT (Neofetch), and C# (Nextcloud).
  • Adds a C# sample that demonstrates building and running a custom container image via the SDK’s <WslcImage> MSBuild integration.
  • Adds a samples index README plus a samples-local .gitignore to support keeping these hand-authored project files in-repo.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
doc/samples/WSLC-NextCloud/WSLCNextCloud.csproj New .NET 8 console project referencing Microsoft.WSL.Containers.
doc/samples/WSLC-NextCloud/README.md Build/run/storage instructions for the Nextcloud sample.
doc/samples/WSLC-NextCloud/Program.cs C# sample that pulls nextcloud and runs it with port + volume mapping.
doc/samples/WSLC-Neofetch/WSLCNeofetch.vcxproj.filters VS filters file for the Neofetch sample project.
doc/samples/WSLC-Neofetch/WSLCNeofetch.vcxproj C++/WinRT sample project wiring NuGet packages + build settings.
doc/samples/WSLC-Neofetch/WSLCNeofetch.sln VS solution for building the Neofetch sample.
doc/samples/WSLC-Neofetch/README.md Build/run instructions for the Neofetch sample.
doc/samples/WSLC-Neofetch/packages.config NuGet dependencies for the C++/WinRT Neofetch sample.
doc/samples/WSLC-Neofetch/neofetch.cpp C++/WinRT sample that runs neofetch in a container and streams output.
doc/samples/WSLC-HelloWorld/WSLCHelloWorld.vcxproj C sample project wiring the WSLC SDK package.
doc/samples/WSLC-HelloWorld/WSLCHelloWorld.sln VS solution for building the HelloWorld C sample.
doc/samples/WSLC-HelloWorld/README.md Build/run instructions for the HelloWorld sample.
doc/samples/WSLC-HelloWorld/packages.config NuGet dependency for the HelloWorld sample.
doc/samples/WSLC-HelloWorld/helloworld.c Minimal C sample using the flat wslcsdk.h API to run echo.
doc/samples/WSLC-CustomContainer/WSLCCustomContainer.csproj C# project that auto-builds a custom image via <WslcImage>.
doc/samples/WSLC-CustomContainer/README.md Explains the <WslcImage> auto-build flow and how to run the sample.
doc/samples/WSLC-CustomContainer/Program.cs C# sample that loads a locally-built image tar and runs a Python tool inside.
doc/samples/WSLC-CustomContainer/Container/qr.py Python tool that prints an ASCII/Unicode QR code in the container.
doc/samples/WSLC-CustomContainer/Container/Containerfile Containerfile that installs qrcode and copies qr.py.
doc/samples/README.md Top-level index describing all four samples.
doc/samples/.gitignore Samples-local ignore rules + re-includes for project files normally ignored at repo root.

Comment thread doc/samples/WSLC-Neofetch/neofetch.cpp
Comment thread doc/samples/WSLC-HelloWorld/helloworld.c Outdated
Comment thread doc/samples/WSLC-CustomContainer/Program.cs Fixed
Comment thread doc/samples/WSLC-CustomContainer/Program.cs Fixed
Comment thread doc/samples/WSLC-CustomContainer/Program.cs Fixed

@OneBlue OneBlue left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good overall, couple minor comments

I also recommend add a pipeline to validate that all of these actually build (we can use a GH pipeline to make this easy, and only trigger it when doc/samples is edited

Comment thread doc/samples/WSLC-CustomContainer/Program.cs Outdated
Comment thread doc/samples/WSLC-HelloWorld/helloworld.c Outdated
Comment thread doc/samples/WSLC-HelloWorld/helloworld.c Outdated
Comment thread doc/samples/WSLC-HelloWorld/helloworld.c Outdated
Comment thread doc/samples/WSLC-HelloWorld/helloworld.c Outdated
Comment thread doc/samples/WSLC-Neofetch/neofetch.cpp Outdated
Comment thread doc/samples/WSLC-Neofetch/neofetch.cpp Outdated
Comment thread doc/samples/WSLC-NextCloud/Program.cs Outdated
Comment on lines +112 to +115
catch (Exception ex)
{
Console.Error.WriteLine($"[wslc] Error: {ex.Message}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants