Add MSBuild and CMake build integration for WSLC container images#14551
Add MSBuild and CMake build integration for WSLC container images#14551shuaiyuanxx wants to merge 7 commits intomasterfrom
Conversation
|
Hey @shuaiyuanxx 👋 — Following up on this draft PR. There are 11 unresolved review threads covering design and implementation feedback (flag file vs tar output, image save requirement, target naming, GLOB_RECURSE validation, VS design-time build interference, etc.). Is this still actively being developed? The PR is marked DO NOT MERGE — just checking in on the status and whether the approach is still the planned direction. |
Hi @benhillis, thanks for following up. Yes — this is still actively being developed. The design direction has been reviewed and approved via the spec. This PR is ready for review now. |
|
The |
40f6148 to
acc6bcf
Compare
Summary of the Pull Request
Add build-system integration to the
Microsoft.WSL.ContainersNuGet package so that developers can declaratively build WSLC container images as part of their MSBuild (C++/C#) and CMake workflows, with full incremental rebuild support.Developers declare
<WslcImage>items (MSBuild) or callwslc_add_image()(CMake) in their project, and the build system automatically invokeswslc image buildafter the main build, skipping the step when sources haven't changed.PR Checklist
Detailed Description of the Pull Request / Additional comments
New files
build/Microsoft.WSL.Containers.common.targetsWSLC0001), item metadata validation (WSLC0002–WSLC0004), incremental image build via stamp files, design-time build guard, and clean targetbuild/native/Microsoft.WSL.Containers.targets.tlogfiles for VS Fast Up-to-Date Checkbuild/net/Microsoft.WSL.Containers.targetsUpToDateCheckInput/UpToDateCheckBuiltitems for VS up-to-date checkcmake/Microsoft.WSL.ContainersConfig.cmakewslc_add_image()CMake function with target name validation, IMAGE validation, path normalization,CONFIGURE_DEPENDSglob, and CONTEXT fallback when SOURCES is omittedUsage — MSBuild (C++ / C#)
Usage — CMake
Key design decisions
Inputs/Outputsand CMakeDEPENDS/OUTPUTuse a timestamp stamp file (wslc_<name>.built) to skip rebuilds when no source files have changed.wslc image buildis the terminal step; image save/export is not included and can be added later whenwslc image savestabilizes.Sourcesmetadata is escaped via$([MSBuild]::Escape())before passing through MSBuild taskProperties=, and unescaped at the consumption site, so multi-directory paths work correctly.$(DesignTimeBuild) == 'true'to avoid slowing down the VS IDE.DockerfileandContextare required;Identityis validated against invalid filename characters with actionable error codes (WSLC0001–WSLC0004). CMakeIMAGEparameter is validated to not contain:(useTAGseparately).Validation Steps Performed
All tests run locally against wslc 2.8.1 on Windows 11 (26200):
WSLC0002/→ errorWSLC0004FATAL_ERROR:→FATAL_ERROR