Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions msipackage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ foreach(binary ${WINDOWS_BINARIES})
list(APPEND BINARIES_DEPENDENCIES "${PACKAGE_INPUT_DIR}/${binary}")
endforeach()

# Shell script for WSL interop (allows running 'wslc' without the .exe extension inside WSL)
list(APPEND BINARIES_DEPENDENCIES "${CMAKE_SOURCE_DIR}/src/windows/wslc/wslc")

set(LINUX_BINARIES init;initrd.img)
foreach(binary ${LINUX_BINARIES})
list(APPEND BINARIES_DEPENDENCIES "${BIN}/${binary}")
Expand Down
1 change: 1 addition & 0 deletions msipackage/package.wix.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

<File Id="wslg.exe" Name="wslg.exe" Source="${PACKAGE_INPUT_DIR}/wslg.exe" />
<File Id="wslc.exe" Name="wslc.exe" Source="${PACKAGE_INPUT_DIR}/wslc.exe" />
<File Id="wslc" Name="wslc" Source="${CMAKE_SOURCE_DIR}/src/windows/wslc/wslc" />
<File Id="wslhost.exe" Name="wslhost.exe" Source="${PACKAGE_INPUT_DIR}/wslhost.exe" />
<File Id="wslrelay.exe" Name="wslrelay.exe" Source="${PACKAGE_INPUT_DIR}/wslrelay.exe" />
<File Id="wslserviceproxystub.dll" Name="wslserviceproxystub.dll" Source="${PACKAGE_INPUT_DIR}/wslserviceproxystub.dll" />
Expand Down
2 changes: 2 additions & 0 deletions src/windows/wslc/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Shell scripts must keep Unix (LF) line endings to work in WSL
wslc text eol=lf
12 changes: 12 additions & 0 deletions src/windows/wslc/wslc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env sh
#
# Copyright (c) Microsoft. All rights reserved.
#
# Shell script to allow running wslc from within a WSL distribution
# without needing the .exe extension (e.g. 'wslc' instead of 'wslc.exe').

WSL_PATH="$(dirname "$(realpath "$0")")"
WSLC_EXE="$WSL_PATH/wslc.exe"

"$WSLC_EXE" "$@"
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.

nit: We could exec to avoid creating an additional process

exit $?
Comment on lines +11 to +12
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The wrapper runs wslc.exe as a child process and then explicitly exit $?. Using exec "$WSLC_EXE" "$@" would replace the shell process with wslc.exe, avoiding an extra process and ensuring signal/exit-code behavior matches the underlying CLI more directly (e.g., Ctrl-C / SIGINT handling).

Suggested change
"$WSLC_EXE" "$@"
exit $?
exec "$WSLC_EXE" "$@"

Copilot uses AI. Check for mistakes.
10 changes: 10 additions & 0 deletions test/windows/SimpleTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,15 @@ class SimpleTests
VERIFY_IS_TRUE(output.find(L"/mnt/c/Program Files (x86)/Common Files") != std::wstring::npos);
VERIFY_IS_TRUE(output.find(L"/mnt/c/Users/Test User/AppData/Local/Programs/Microsoft VS Code/bin") != std::wstring::npos);
}

TEST_METHOD(WslcShellScript)
{
// Verify that the 'wslc' shell script (no .exe extension) invokes wslc.exe
// and produces the same output as calling wslc.exe directly.
auto [exeOutput, exeErr] = LxsstuLaunchWslAndCaptureOutput(L"wslc.exe version");
auto [scriptOutput, scriptErr] = LxsstuLaunchWslAndCaptureOutput(L"wslc version");
VERIFY_ARE_EQUAL(exeOutput, scriptOutput);
VERIFY_ARE_EQUAL(exeErr, scriptErr);
}
};
} // namespace SimpleTests
Loading