Add .NET DLL for SDK projection to NuGet package#40182
Add .NET DLL for SDK projection to NuGet package#40182florelis wants to merge 3 commits intomicrosoft:feature/wsl-for-appsfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for shipping a C# projection DLL (wslcsdkcs.dll) in the Microsoft.WSL.Containers NuGet package, and updates build/targets logic so consumers get correct native asset layout and copy behavior.
Changes:
- Introduces a CMake helper (
configure_csharp_target) and a new C# CMake target forwslcsdkcs. - Updates NuGet package layout to place native binaries under
runtimes/win-<arch>/native/and adds new MSBuild targets fornet8.0. - Updates CMake package config and NuGet spec to reference the new locations and include the new managed DLL.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/windows/wslsettings/CMakeLists.txt | Switches to shared C# target configuration helper and removes duplicated per-target settings. |
| src/windows/WslcSDK/csharp/Projection.cs | Adds placeholder C# source for the new projection DLL. |
| src/windows/WslcSDK/csharp/CMakeLists.txt | Adds new C# shared library target wslcsdkcs. |
| nuget/Microsoft.WSL.Containers/cmake/Microsoft.WSL.ContainersConfig.cmake | Updates imported DLL path to native/ subfolder. |
| nuget/Microsoft.WSL.Containers/build/net8.0/Microsoft.WSL.Containers.targets | Adds net8-specific copy logic (RID/PlatformTarget fallback) and erroring. |
| nuget/Microsoft.WSL.Containers/build/net/Microsoft.WSL.Containers.targets | Removes old net targets file. |
| nuget/Microsoft.WSL.Containers/build/native/Microsoft.WSL.Containers.targets | Updates native targets and attempts DLL copy via MSBuild items. |
| nuget/Microsoft.WSL.Containers/build/Microsoft.WSL.Containers.common.targets | Removes common targets file previously used for copying/erroring. |
| nuget/Microsoft.WSL.Containers.nuspec.in | Adds wslcsdkcs.dll and moves native DLLs under native/. |
| cmake/findCSharp.cmake | Adds configure_csharp_target() helper (C# flags + Windows SDK MSBuild properties). |
| CMakeLists.txt | Adds find_package(CSharp) and adds the new C# subdirectory build. |
| .gitignore | Normalizes *.etl entry and adds *.lscache. |
JohnMcPMS
left a comment
There was a problem hiding this comment.
I approve, but I am not a cmake expert so I would want one of the primary maintainers to make sure that part is good.
| <PropertyGroup> | ||
| <WslcPlatform Condition="'$(WslcPlatform)' == ''">$(Platform)</WslcPlatform> | ||
| <_wslcIsInvalidPlatform Condition="'$(WslcPlatform)' != 'x64' and '$(WslcPlatform)' != 'arm64'">true</_wslcIsInvalidPlatform> | ||
| </PropertyGroup> |
There was a problem hiding this comment.
WslcPlatform defaults to $(Platform) but VS commonly sets $(Platform) to ARM64 (uppercase). Since the package folder is runtimes\win-arm64, the current comparison/path will treat ARM64 as invalid and also generate incorrect paths. Consider normalizing/mapping platform values (e.g., lowercase + map ARM64->arm64) before validation and before constructing runtimes\win-... paths.
| set(CMAKE_DOTNET_TARGET_FRAMEWORK "net8.0-windows${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") | ||
| set(WSL_NUGET_TARGET_FRAMEWORK "net8.0-windows10.0.19041.0") |
There was a problem hiding this comment.
CMAKE_DOTNET_TARGET_FRAMEWORK is set from CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION (e.g., 10.0.26100.0), but the NuGet lib folder uses WSL_NUGET_TARGET_FRAMEWORK = net8.0-windows10.0.19041.0. This can produce a managed wslcsdkcs.dll built for a higher Windows TFM being packaged under a lower TFM, which can mislead asset selection and break consumers on older Windows versions once the projection uses newer APIs. Align the built TFM with the package TFM (or vice versa), or set the DOTNET_TARGET_FRAMEWORK for wslcsdkcs explicitly to match WSL_NUGET_TARGET_FRAMEWORK.
| set(CMAKE_DOTNET_TARGET_FRAMEWORK "net8.0-windows${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") | |
| set(WSL_NUGET_TARGET_FRAMEWORK "net8.0-windows10.0.19041.0") | |
| set(WSL_NUGET_TARGET_FRAMEWORK "net8.0-windows10.0.19041.0") | |
| set(CMAKE_DOTNET_TARGET_FRAMEWORK "${WSL_NUGET_TARGET_FRAMEWORK}") |
| add_subdirectory(src/windows/WslcSDK/csharp) | ||
|
|
||
| if (WSL_BUILD_WSL_SETTINGS) |
There was a problem hiding this comment.
src/windows/WslcSDK/csharp is added unconditionally, which means a C#/.NET toolchain is now required even when WSL_BUILD_WSL_SETTINGS is false. If the intent is only to build/package the C# projection in specific scenarios, consider guarding this add_subdirectory(...) (and the find_package(CSharp REQUIRED)) behind an option/flag so core/native-only builds don’t start failing on machines without the C# build tools installed.
| add_subdirectory(src/windows/WslcSDK/csharp) | |
| if (WSL_BUILD_WSL_SETTINGS) | |
| if (WSL_BUILD_WSL_SETTINGS) | |
| add_subdirectory(src/windows/WslcSDK/csharp) |
Summary of the Pull Request
wslcsdkcs.dll, that will include the SDK projection for C#.PR Checklist
Detailed Description of the Pull Request / Additional comments
wslsettingstarget and reused for the newwslcsdkcs..targetsto use a proper TFM (net8.0instead ofnet), to check$(PlatformTarget)as a fallback when$(RuntimeIdentifier)is not set.runtimes\win-<arch>\toruntimes\win-<arch>\native\, where MSBuild knows to automatically reference and copy them for .NET projects using$(RuntimeIdentifier)Validation Steps Performed
Manually created C# projects and confirmed that the right files were being referenced and copied. More proper validation will come later in the form of sample apps.