-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add .NET DLL for SDK projection to NuGet package #40182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/wsl-for-apps
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,4 +68,5 @@ directory.build.targets | |
| test-storage/ | ||
| *.vhdx | ||
| *.tar | ||
| *.etl | ||
| *.etl | ||
| *.lscache | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -81,6 +81,7 @@ find_package(NUGET REQUIRED) | |||||||||||||
| find_package(VERSION REQUIRED) | ||||||||||||||
| find_package(MC REQUIRED) | ||||||||||||||
| find_package(Appx REQUIRED) | ||||||||||||||
| find_package(CSharp REQUIRED) | ||||||||||||||
|
|
||||||||||||||
| # Download nuget packages | ||||||||||||||
| restore_nuget_packages() | ||||||||||||||
|
|
@@ -272,6 +273,11 @@ if (${TARGET_PLATFORM} STREQUAL "x64") | |||||||||||||
| set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /CETCOMPAT") | ||||||||||||||
| endif() | ||||||||||||||
|
|
||||||||||||||
| set(CMAKE_CSharp_FLAGS "${CMAKE_CSharp_FLAGS} /langversion:latest /debug:full") | ||||||||||||||
| set(CMAKE_DOTNET_SDK "Microsoft.NET.Sdk") | ||||||||||||||
| 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") | ||||||||||||||
|
Comment on lines
+278
to
+279
|
||||||||||||||
| 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}") |
Copilot
AI
Apr 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| function(configure_csharp_target TARGET) | ||
| set(TARGET_PLATFORM_MIN_VERSION "10.0.19041.0") | ||
|
|
||
| set_target_properties( | ||
| ${TARGET} PROPERTIES | ||
| VS_GLOBAL_TargetPlatformVersion "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}" | ||
| VS_GLOBAL_TargetPlatformMinVersion "${TARGET_PLATFORM_MIN_VERSION}" | ||
| VS_GLOBAL_WindowsSdkPackageVersion "${WINDOWS_SDK_DOTNET_VERSION}" | ||
| VS_GLOBAL_AppendRuntimeIdentifierToOutputPath false | ||
| VS_GLOBAL_GenerateAssemblyInfo false | ||
| VS_GLOBAL_TargetLatestRuntimePatch false | ||
| ) | ||
| endfunction() |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <PropertyGroup Condition="'$(WSLCSDK_Platform)' == ''"> | ||
|
florelis marked this conversation as resolved.
|
||
| <WSLCSDK_Platform>$(Platform)</WSLCSDK_Platform> | ||
| <PropertyGroup> | ||
| <WslcPlatform Condition="'$(WslcPlatform)' == ''">$(Platform)</WslcPlatform> | ||
| <_wslcIsInvalidPlatform Condition="'$(WslcPlatform)' != 'x64' and '$(WslcPlatform)' != 'arm64'">true</_wslcIsInvalidPlatform> | ||
| </PropertyGroup> | ||
|
Comment on lines
+3
to
6
|
||
|
|
||
| <ItemDefinitionGroup> | ||
| <ClCompile> | ||
| <AdditionalIncludeDirectories> | ||
|
|
@@ -16,11 +18,17 @@ | |
| %(AdditionalDependencies) | ||
| </AdditionalDependencies> | ||
| <AdditionalLibraryDirectories> | ||
| $(MSBuildThisFileDirectory)..\..\runtimes\win-$(Platform); | ||
| $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WslcPlatform); | ||
| %(AdditionalLibraryDirectories) | ||
| </AdditionalLibraryDirectories> | ||
| </Link> | ||
| </ItemDefinitionGroup> | ||
|
|
||
| <Import Project="$(MSBuildThisFileDirectory)..\Microsoft.WSL.Containers.common.targets" /> | ||
| <ItemGroup> | ||
| <ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-$(WslcPlatform)\native\wslcsdk.dll" /> | ||
| </ItemGroup> | ||
|
florelis marked this conversation as resolved.
|
||
|
|
||
| <Target Name="WslcValidatePlatform" BeforeTargets="PrepareForBuild" Condition="'$(_wslcIsInvalidPlatform)' == 'true'"> | ||
| <Error Text="wslcsdk.dll could not be copied because platform '$(WslcPlatform)' is not supported. Only x64 and arm64 platforms are supported." /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should mention the resolution: "Set [GH did not offer me the "suggest a change" button 🐸] |
||
| </Target> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,31 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <PropertyGroup Condition="'$(WSLCSDK_Platform)' == ''"> | ||
| <WSLCSDK_Platform Condition="$(RuntimeIdentifier.EndsWith('-x64'))">x64</WSLCSDK_Platform> | ||
| <WSLCSDK_Platform Condition="$(RuntimeIdentifier.EndsWith('-arm64'))">arm64</WSLCSDK_Platform> | ||
| </PropertyGroup> | ||
| <!-- If we have a RuntimeIdentifier, the DLL is referenced automatically. | ||
| If it is missing, we fall back to PlatformTarget to reference it manually. --> | ||
| <Choose> | ||
| <When Condition="'$(RuntimeIdentifier)' != ''"> | ||
| <PropertyGroup> | ||
| <_wslcPlatform Condition="$(RuntimeIdentifier.EndsWith('-x64'))">x64</_wslcPlatform> | ||
| <_wslcPlatform Condition="$(RuntimeIdentifier.EndsWith('-arm64'))">arm64</_wslcPlatform> | ||
| <_wslcInvalidPlatformProperty Condition="'$(_wslcPlatform)' == ''">RuntimeIdentifier</_wslcInvalidPlatformProperty> | ||
| <_wslcInvalidPlatform Condition="'$(_wslcPlatform)' == ''">$(RuntimeIdentifier)</_wslcInvalidPlatform> | ||
| </PropertyGroup> | ||
| </When> | ||
| <Otherwise> | ||
| <PropertyGroup> | ||
| <_wslcPlatform Condition="'$(PlatformTarget)' == 'x64'">x64</_wslcPlatform> | ||
| <_wslcPlatform Condition="'$(PlatformTarget)' == 'arm64'">arm64</_wslcPlatform> | ||
| <_wslcInvalidPlatformProperty Condition="'$(_wslcPlatform)' == ''">PlatformTarget</_wslcInvalidPlatformProperty> | ||
| <_wslcInvalidPlatform Condition="'$(_wslcPlatform)' == ''">$(PlatformTarget)</_wslcInvalidPlatform> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Condition="'$(WSLCSDK_Platform)' == ''"> | ||
| <WSLCSDK_Platform Condition="'$(Platform)' != 'AnyCPU'">$(Platform)</WSLCSDK_Platform> | ||
| </PropertyGroup> | ||
|
|
||
| <Import Project="$(MSBuildThisFileDirectory)..\Microsoft.WSL.Containers.common.targets" /> | ||
| <ItemGroup Condition="'$(_wslcPlatform)' != ''"> | ||
| <ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-$(_wslcPlatform)\native\wslcsdk.dll" /> | ||
| </ItemGroup> | ||
| </Otherwise> | ||
| </Choose> | ||
|
|
||
| <Target Name="WslcValidatePlatform" BeforeTargets="PrepareForBuild" Condition="'$(_wslcInvalidPlatform)' != ''"> | ||
| <Error Text="wslcsdk.dll could not be copied because the $(_wslcInvalidPlatformProperty) '$(_wslcInvalidPlatform)' is not supported. Only x64 and arm64 platforms are supported." /> | ||
| </Target> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| enable_language(CSharp) | ||
|
|
||
| add_library(wslcsdkcs SHARED "Projection.cs") | ||
| configure_csharp_target(wslcsdkcs) | ||
|
|
||
| set_target_properties( | ||
| wslcsdkcs PROPERTIES | ||
| FOLDER windows | ||
| LINKER_LANGUAGE CSharp | ||
| VS_GLOBAL_PlatformTarget "AnyCPU" | ||
| ) | ||
|
|
||
| add_dependencies(wslcsdkcs wslcsdk) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| namespace Microsoft.WSL.Containers | ||
| { | ||
| // This is only a placeholder so that we can compile a DLL. | ||
| // The actual implementation of the projection will be added later. | ||
| internal class Projection | ||
| { | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.