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
11 changes: 11 additions & 0 deletions src/windows/wslc/wslc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/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")")"
Comment thread
benhillis marked this conversation as resolved.
WSLC_EXE="$WSL_PATH/wslc.exe"

exec "$WSLC_EXE" "$@"
14 changes: 14 additions & 0 deletions test/windows/SimpleTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,19 @@ 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);
}

WSLC_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.
// Use the full install path since the MSI directory may not be on %PATH% in CI.
auto installPath = wsl::windows::common::wslutil::GetMsiPackagePath().value();
auto exeCmd = std::format(L"$(wslpath '{}wslc.exe') version", installPath);
auto scriptCmd = std::format(L"$(wslpath '{}wslc') version", installPath);
auto [exeOutput, exeErr] = LxsstuLaunchWslAndCaptureOutput(exeCmd);
auto [scriptOutput, scriptErr] = LxsstuLaunchWslAndCaptureOutput(scriptCmd);
VERIFY_ARE_EQUAL(exeOutput, scriptOutput);
Comment thread
benhillis marked this conversation as resolved.
VERIFY_ARE_EQUAL(exeErr, scriptErr);
}
};
} // namespace SimpleTests
Loading