Initial open source commit for WSL.

Many Microsoft employees have contributed to the Windows Subsystem for Linux, this commit is the result of their work since 2016.

The entire history of the Windows Subsystem for Linux can't be shared here, but here's an overview of WSL's history after it moved to it own repository in 2021:

Number of commits on the main branch: 2930
Number of contributors: 31

Head over https://github.com/microsoft/WSL/releases for a more detailed history of the features added to WSL since 2021.
This commit is contained in:
WSL Team 2025-05-15 12:09:45 -07:00 committed by Blue
parent 9f6c33f4a7
commit 697572d664
740 changed files with 260952 additions and 209 deletions

149
.clang-format Normal file
View file

@ -0,0 +1,149 @@
---
# this file work is a derivative of onecoreuap/net/.clang-format
# https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md
#
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignEscapedNewlines: DontAlign
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
ColumnLimit: 130
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"(stdafx.h|pch.h|precomp.h)"$'
Priority: -1
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: '^BEGIN_COM_MAP$|^BEGIN_CONNECTION_POINT_MAP$|^BEGIN_HELPER_NODEMAP$|^BEGIN_MODULE$|^BEGIN_MSG_MAP$|^BEGIN_OBJECT_MAP$|^BEGIN_TEST_CLASS$|^BEGIN_TEST_METHOD$|^BEGIN_TEST_METHOD_PROPERTIES$'
MacroBlockEnd: '^END_COM_MAP$|^END_CONNECTION_POINT_MAP$|^END_HELPER_NODEMAP$|^END_MODULE$|^END_MSG_MAP$|^END_OBJECT_MAP$|^END_TEST_CLASS$|^END_TEST_METHOD$|^END_TEST_METHOD_PROPERTIES$'
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros: [
_Acquires_exclusive_lock_,
_Acquires_lock_,
_Acquires_nonreentrant_lock_,
_Acquires_shared_lock_,
_Analysis_assume_smart_lock_acquired_,
_Analysis_assume_smart_lock_released_,
_Create_lock_level_,
_Detaches_lock_,
_Function_class_,
_Global_cancel_spin_lock_,
_Global_critical_region_,
_Global_interlock_,
_Global_priority_region_,
_Has_lock_kind_,
_Has_lock_level_,
_IRQL_always_function_max_,
_IRQL_always_function_min_,
_IRQL_raises_,
_IRQL_requires_,
_IRQL_requires_max_,
_IRQL_requires_min_,
_IRQL_requires_same_,
_IRQL_restores_,
_IRQL_restores_global_,
_IRQL_saves_,
_IRQL_saves_global_,
_Lock_level_order_,
_Moves_lock_,
_Must_inspect_result_,
_No_competing_thread_,
_Post_same_lock_,
_Post_writable_byte_size_,
_Pre_satisfies_,
_Releases_exclusive_lock_,
_Releases_lock_,
_Releases_nonreentrant_lock_,
_Releases_shared_lock_,
_Replaces_lock_,
_Requires_exclusive_lock_held_,
_Requires_lock_held_,
_Requires_lock_not_held_,
_Requires_no_locks_held_,
_Requires_shared_lock_held_,
_Ret_maybenull_,
_Ret_range_,
_Success_,
_Swaps_locks_,
_Use_decl_annotations_,
_When_,
RpcEndExcept,
]
TabWidth: 4
TypenameMacros: [
IFACEMETHOD,
STDMETHOD,
]
UseTab: Never
...

326
.gdnsuppress Normal file
View file

@ -0,0 +1,326 @@
{
"hydrated": false,
"properties": {
"helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/suppressions"
},
"version": "1.0.0",
"suppressionSets": {
"default": {
"name": "default",
"createdDate": "2025-04-30 22:17:21Z",
"lastUpdatedDate": "2025-04-30 22:17:21Z"
}
},
"results": {
"3d7d59d41a06e01093616033ddd4ecec1e8dcb65363768638eea6acb6d012b4e": {
"signature": "3d7d59d41a06e01093616033ddd4ecec1e8dcb65363768638eea6acb6d012b4e",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"aa145b1818ed203013a6267ca382110ec5ea9c1bf50a812964d4c7b5671224ec": {
"signature": "aa145b1818ed203013a6267ca382110ec5ea9c1bf50a812964d4c7b5671224ec",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"c5f15f6ef4ac3f1e82c31ae0f651ab0f1c8448e34824bf231dd2104cef70d9e5": {
"signature": "c5f15f6ef4ac3f1e82c31ae0f651ab0f1c8448e34824bf231dd2104cef70d9e5",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"e8eb99fd7876f9c79c0ff194de9e21cc77d63573a9b73ba1666778a247dcebff": {
"signature": "e8eb99fd7876f9c79c0ff194de9e21cc77d63573a9b73ba1666778a247dcebff",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"43df748a685bc9feca8cf04c518f57a82012d61665dca65d8a1fb652a55d9391": {
"signature": "43df748a685bc9feca8cf04c518f57a82012d61665dca65d8a1fb652a55d9391",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"fc58019c679cf3c469af5161b1f237f7552ee81c3d3ae29aff2d18fcceafe3e7": {
"signature": "fc58019c679cf3c469af5161b1f237f7552ee81c3d3ae29aff2d18fcceafe3e7",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"bedcd464fd4426dbd786cb09b7407100aa548dfff85d3c89e7fd79c8c2623391": {
"signature": "bedcd464fd4426dbd786cb09b7407100aa548dfff85d3c89e7fd79c8c2623391",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"06d5d116da395c14acda7a67c6530e675cc6d59593a94f37fbc2b91ce05380ca": {
"signature": "06d5d116da395c14acda7a67c6530e675cc6d59593a94f37fbc2b91ce05380ca",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"a93af66a96249e7041eee45e325c2548da917d4c6984e7cf67fa0c052a01a980": {
"signature": "a93af66a96249e7041eee45e325c2548da917d4c6984e7cf67fa0c052a01a980",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"2950fa4920cef845442e43dccfbdd49ca5935a1f0aa115c3b25bf5397d39bac7": {
"signature": "2950fa4920cef845442e43dccfbdd49ca5935a1f0aa115c3b25bf5397d39bac7",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"d747605a4cb9b5cbe7715f638b3909572302db204327120c50f712064c405380": {
"signature": "d747605a4cb9b5cbe7715f638b3909572302db204327120c50f712064c405380",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"be9c9eacd39f7740ac8794956f9133718e7bac4556a7a29ebdbcae5a1c762faf": {
"signature": "be9c9eacd39f7740ac8794956f9133718e7bac4556a7a29ebdbcae5a1c762faf",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"1af653b6acce89da21e37933f80d0686bf8a01aab386620533b42e06b55a3f26": {
"signature": "1af653b6acce89da21e37933f80d0686bf8a01aab386620533b42e06b55a3f26",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"5ba96332382fbe9cfb5c6baf51b5bd6e2644f1aa86c3fad66562dd648458f431": {
"signature": "5ba96332382fbe9cfb5c6baf51b5bd6e2644f1aa86c3fad66562dd648458f431",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"29432097a113f870ee7f86e585601fa1a6013f50b65893a359391ef47f996c73": {
"signature": "29432097a113f870ee7f86e585601fa1a6013f50b65893a359391ef47f996c73",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"352c2da0bfcde6f9f60c43359e7263b07247d26bff0343a369c8e3667c37fbe1": {
"signature": "352c2da0bfcde6f9f60c43359e7263b07247d26bff0343a369c8e3667c37fbe1",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"64bf4920e1b5b21e7312594ca9d95e3b48ac05a9cef507b21d91ba588a0ab08e": {
"signature": "64bf4920e1b5b21e7312594ca9d95e3b48ac05a9cef507b21d91ba588a0ab08e",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"720d1478e66c5f46670729c232d5afb787cdcc007f53e67d31edd4457e60967c": {
"signature": "720d1478e66c5f46670729c232d5afb787cdcc007f53e67d31edd4457e60967c",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"cf0a86680efb56a7eb351df85c51c6ad2e1ae64f108b8729ab7a9dd148d8312b": {
"signature": "cf0a86680efb56a7eb351df85c51c6ad2e1ae64f108b8729ab7a9dd148d8312b",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"3cedf840f8bdf45d29de68eedf06e3548fbdf86ebe3929c38b1be7babd790142": {
"signature": "3cedf840f8bdf45d29de68eedf06e3548fbdf86ebe3929c38b1be7babd790142",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"2e746764a2b4ee4971e2afded4c2dd99c5bf7647a5c8d9ae027d901caf7c5982": {
"signature": "2e746764a2b4ee4971e2afded4c2dd99c5bf7647a5c8d9ae027d901caf7c5982",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"04e31f322d76e5b2d92d36987ae5453b9d7b4eb1aba2e59f9956e088756eb3d3": {
"signature": "04e31f322d76e5b2d92d36987ae5453b9d7b4eb1aba2e59f9956e088756eb3d3",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"df6145ffc4e1301e28b405ec934470ab2346ac60ef1b5a806a470f6a86907141": {
"signature": "df6145ffc4e1301e28b405ec934470ab2346ac60ef1b5a806a470f6a86907141",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"53daee355a750916f6516911381cd31bfbb8de644cb0158a7bfb6456ffab163c": {
"signature": "53daee355a750916f6516911381cd31bfbb8de644cb0158a7bfb6456ffab163c",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"cf5679eb50b6062e91bab7a9a53aa2c356a41289192081f733e42c6def3abc96": {
"signature": "cf5679eb50b6062e91bab7a9a53aa2c356a41289192081f733e42c6def3abc96",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"9dac4ccae735c85dd3974f876f336accefa2f90f3cea74801bf4b148926bd132": {
"signature": "9dac4ccae735c85dd3974f876f336accefa2f90f3cea74801bf4b148926bd132",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"d05aa96a810d8140a0c2269e8d5e64b8b6db02652da6842547e1e1c4139096b5": {
"signature": "d05aa96a810d8140a0c2269e8d5e64b8b6db02652da6842547e1e1c4139096b5",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"cd0ad7bf2ffe4b3d068dc6c9731aa1d8f001250f30ebd3667a8982f03e72c879": {
"signature": "cd0ad7bf2ffe4b3d068dc6c9731aa1d8f001250f30ebd3667a8982f03e72c879",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"8415dbbf5b26dadc3e7d7f09b496a7f53452c60b67019bbb92c48dd1cd0f703a": {
"signature": "8415dbbf5b26dadc3e7d7f09b496a7f53452c60b67019bbb92c48dd1cd0f703a",
"alternativeSignatures": [
"88c2fa648d6200a3832a1a4b6d568c43a9dd89e05e4032c4286450c4d3a9171d"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"20edc36496c8274a97fe9179b56fcc1b5aab4b7e0d6769c23e14181844f64f35": {
"signature": "20edc36496c8274a97fe9179b56fcc1b5aab4b7e0d6769c23e14181844f64f35",
"alternativeSignatures": [
"14b018ac237bbbfe6304e73f454e190a2c60d335f249db0a9af6500eeae4808f"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
},
"2652e38833372ca84eeebf1e9cd6145d4556e3851f7e698f95b5f01574cef372": {
"signature": "2652e38833372ca84eeebf1e9cd6145d4556e3851f7e698f95b5f01574cef372",
"alternativeSignatures": [
"d705445d04087b944ab3e7777bce5c61a4efc64fc7be2953cf7ed8573321a87b"
],
"memberOf": [
"default"
],
"createdDate": "2025-04-30 22:17:21Z"
}
}
}

4
.github/CODEOWNERS vendored Normal file
View file

@ -0,0 +1,4 @@
# File containing policy for file ownership
# Reviewers for all files in the repository
* @microsoft/wsl-maintainers

18
.github/pull_request_template.md vendored Normal file
View file

@ -0,0 +1,18 @@
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
## Summary of the Pull Request
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
- [ ] **Closes:** Link to issue #xxx
- [ ] **Communication:** I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated if needed and all pass
- [ ] **Localization:** All end user facing strings can be localized
- [ ] **Dev docs:** Added/updated if needed
- [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/wsl/) and link it here: #xxx
<!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

35
.github/workflows/documentation.yml vendored Normal file
View file

@ -0,0 +1,35 @@
name: Build documentation
on:
workflow_dispatch:
push:
branches: [main, master]
jobs:
DeployDocs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
steps:
- name: Checkout actions
uses: actions/checkout@v4
- name: Install packages
run: pip install mkdocs-mermaid2-plugin mkdocs --break-system-packages
shell: bash
- name: Build documentation
run: mkdocs build -f doc/mkdocs.yml
shell: bash
- uses: actions/upload-pages-artifact@v3
with:
path: doc/site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

67
.gitignore vendored Normal file
View file

@ -0,0 +1,67 @@
.vscode/*
.vs/
!vendor/.preserve
out
tmp
/.vs/
/.vscode/
*.sln
*.user
*.csproj
*.vcxproj
*.targets
*.filters
*.pdb
*.lib
*.dll
obj/
Debug/
Release/
Properties/
/_deps/
/package/Strings/en-US/
/packages/
CMakeFiles/
CMakeCache.txt
*.msix
cmake_install.cmake
build_tools/
*_i.c
*_p.c
*_p.c
wslsupport/wslsupport.h
dlldata.c
.gdbinit
llvm/
*.a
*.so
*.o
linux/init/init
linux/init
initrd/init
bin/
*.nupkg
build/
generated/
Microsoft.WSL.PluginApi.nuspec
test/linux/unit_tests/wsl_unit_tests
*.dir/
UserConfig.cmake
*.wix
*.wixobj
*.wixpdb
test.bat
AppxManifest.xml
package_layout/
priconf.xml
resources.map.txt
resources.pri
msi-install-*.txt
kernellogs.txt
FormatSource.ps1
msixinstaller/x64
package/x64
/appx-logs.txt
tools/clang-format.exe
/linux-crashes
doc/site/

384
.pipelines/build-stage.yml Normal file
View file

@ -0,0 +1,384 @@
parameters:
- name: isRelease
type: boolean
default: true
- name: packageVersion
type: string
default: ""
- name: isNightly
type: boolean
default: false
- name: nugetPackages
type: object
default:
- Microsoft.WSL.PluginApi.nuspec
- name: traceLoggingConfig
type: string
default: ''
- name: targets
type: object
default:
- target: "wsl;libwsl;wslg;wslservice;wslhost;wslrelay;wslinstaller;wslinstall;initramfs;wslserviceproxystub;wslsettings;wslinstallerproxystub;testplugin"
pattern: "wsl.exe,libwsl.dll,wslg.exe,wslservice.exe,wslhost.exe,wslrelay.exe,wslinstaller.exe,wslinstall.dll,wslserviceproxystub.dll,wslsettings.dll,wslsettings.exe,wslinstallerproxystub.dll,wsldevicehost.dll,lxutil.dll,WSLDVCPlugin.dll,testplugin.dll,wsldeps.dll"
- target: "msixgluepackage"
pattern: "gluepackage.msix"
- target: "msipackage"
pattern: "wsl.msi"
- name: platforms
type: object
default:
- x64
- arm64
- name: esrp
type: object
default:
ConnectedServiceName: "AzureConnection-AME"
signConfigType: "inlineSignParams"
SessionTimeout: 60
MaxConcurrency: 50
MaxRetryAttempts: 5
ServiceEndpointUrl: $(EsrpServiceEndpointUrl)
AuthAKVName: $(EsrpAuthAKVName)
AuthSignCertName: $(EsrpAuthSignCertName)
AppRegistrationClientId: $(EsrpAppRegistrationClientId)
AppRegistrationTenantId: $(EsrpAppRegistrationTenantId)
EsrpClientId: $(EsrpClientId)
stages:
- stage: build
jobs:
- job:
displayName: "Formatting & localization checks"
timeoutInMinutes: 30
pool:
type: windows
variables:
ob_outputDirectory: '$(Build.SourcesDirectory)\out'
steps:
- script: python tools/devops/validate-localization.py localization/strings en-US
displayName: Validate localization resources
- script: python tools\devops\validate-copyright-headers.py src
displayName: Validate copyright headers (src/)
- script: python tools\devops\validate-copyright-headers.py test
displayName: Validate copyright headers (test/)
- task: CMake@1
displayName: "CMake ."
inputs:
workingDirectory: "."
cmakeArgs: .
- task: PowerShell@2
inputs:
targetType: "filePath"
filePath: FormatSource.ps1
arguments: "-ModifiedOnly $false -Verify $true"
displayName: "Clang-format check"
- job: build
displayName: "Build WSL package"
timeoutInMinutes: 120
pool:
type: windows
variables:
NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS: 60
NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS: 60
ob_outputDirectory: '$(Build.SourcesDirectory)\out'
ob_artifactBaseName: 'drop_wsl'
ob_artifactSuffix: '_build'
ob_sdl_codeSignValidation_excludes: -|**testbin\**
Codeql.PublishDatabaseLog: true
Codeql.SourceRoot: src
steps:
- task: CodeQL3000Init@0
inputs:
Enabled: ${{ and(parameters.isNightly, eq(variables['Build.SourceBranch'], 'refs/heads/main'))}}
- task: UseDotNet@2
displayName: Install .NET Core SDK (required by EsrpCodeSigning)
condition: and(succeeded(), eq('${{ parameters.isRelease }}', true))
inputs:
packageType: "sdk"
- task: PowerShell@2
displayName: Set trace logging configuration
condition: ne('${{ parameters.traceLoggingConfig }}', '')
inputs:
targetType: 'inline'
script: 'Set-Content -Path src/windows/inc/traceloggingconfig.h -Value $env:config.replace("\n", "`n")'
env:
config: '${{ parameters.traceLoggingConfig }}'
- task: PowerShell@2
displayName: "Compute package version"
name: version
inputs:
targetType: inline
${{ if eq(parameters.packageVersion, '') }}:
script: |
$gitversion_version = (Select-Xml -Path packages.config -XPath '/packages/package[@id=''GitVersion.CommandLine'']/@version').Node.Value
$env:path = "packages/GitVersion.CommandLine.$gitversion_version/tools;$env:path"
. .\tools\devops\version_functions.ps1
$version = Get-VersionInfo -Nightly $${{ parameters.isNightly }}
Write-Host "##vso[task.setvariable variable=WSL_PACKAGE_VERSION;isOutput=true]$($version.MsixVersion)"
Write-Host "##vso[task.setvariable variable=WSL_NUGET_PACKAGE_VERSION;isOutput=true]$($version.NugetVersion)"
${{ else }}:
script: |
Write-Host "##vso[task.setvariable variable=WSL_PACKAGE_VERSION;isOutput=true]$([string]('${{ parameters.packageVersion }}' + '.0'))"
Write-Host "##vso[task.setvariable variable=WSL_NUGET_PACKAGE_VERSION;isOutput=true]$([string]('${{ parameters.packageVersion }}'))"
- ${{ each platform in parameters.platforms }}:
- task: CMake@1
displayName: "CMake ${{ platform }}"
inputs:
workingDirectory: "."
cmakeArgs: . --fresh -A ${{ platform }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.26100.0 -DPACKAGE_VERSION=$(version.WSL_PACKAGE_VERSION) -DWSL_NUGET_PACKAGE_VERSION=$(version.WSL_NUGET_PACKAGE_VERSION) -DSKIP_PACKAGE_SIGNING=${{ parameters.isRelease }} -DOFFICIAL_BUILD=${{ parameters.isRelease }} -DPIPELINE_BUILD_ID=$(Build.BuildId)
# This additional Restore NuGet package task is added as a workaround for WSL Settings to have its' packages restored properly.
# Without this, building wsl settings may encounter the following error:
#
# The plugin credential provider could not acquire credentials. Authentication may require manual action.
# Consider re-running the command with --interactive for `dotnet`, /p:NuGetInteractive="true" for MSBuild or removing the -NonInteractive switch for `NuGet`
# Response status code does not indicate success: 401 (Unauthorized)
- script: _deps\nuget.exe restore -NonInteractive
- ${{ each target in parameters.targets }}:
- script: cmake --build . --config Release --target ${{ target.target }} -- -m
condition: and(succeeded(), eq('${{ parameters.isRelease }}', true))
displayName: "Build ${{ target.target }} (${{ platform }})"
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@5
displayName: "Sign ${{ target.target }} (${{ platform }})"
condition: and(succeeded(), eq('${{ parameters.isRelease }}', true))
inputs:
ConnectedServiceName: ${{ parameters.esrp.ConnectedServiceName}}
signConfigType: ${{ parameters.esrp.signConfigType }}
SessionTimeout: ${{ parameters.esrp.SessionTimeout }}
MaxConcurrency: ${{ parameters.esrp.MaxConcurrency }}
MaxRetryAttempts: ${{ parameters.esrp.MaxRetryAttempts }}
ServiceEndpointUrl: ${{ parameters.esrp.ServiceEndpointUrl }}
AuthAKVName: ${{ parameters.esrp.AuthAKVName }}
AuthSignCertName: ${{ parameters.esrp.AuthSignCertName }}
AppRegistrationClientId: ${{ parameters.esrp.AppRegistrationClientId }}
AppRegistrationTenantId: ${{ parameters.esrp.AppRegistrationTenantId }}
FolderPath: "bin\\${{ platform }}"
Pattern: "${{ target.pattern }}"
UseMSIAuthentication: true
EsrpClientId: ${{ parameters.esrp.EsrpClientId }}
inlineOperation: |
[
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolSign",
"Parameters" : {
"OpusName" : "Microsoft",
"OpusInfo" : "http://www.microsoft.com",
"FileDigest" : "/fd \"SHA256\"",
"PageHash" : "/NPH",
"TimeStamp" : "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
},
"ToolName" : "sign",
"ToolVersion" : "1.0"
},
{
"KeyCode" : "CP-230012",
"OperationCode" : "SigntoolVerify",
"Parameters" : {},
"ToolName" : "sign",
"ToolVersion" : "1.0"
}
]
# Replace the intermediate wslsettings binaries file with the signed versions so that any future steps building wslsettings will use the signed versions
- task: PowerShell@2
displayName: 'Replace wslsettings binaries in intermediate folder with signed versions'
condition: and(succeeded(), eq('${{ parameters.isRelease }}', true))
inputs:
targetType: inline
script: |
$arch = '${{ platform }}'
$wslsettingsbinpath = "bin\$arch\release\wslsettings"
$wslsettingsobjpath = "src\windows\wslsettings\obj\$arch\release"
# Update the timestamp of wslsettings.exe so that it doesn't get rebuilt
(Get-Item $wslsettingsbinpath\wslsettings.exe).LastWriteTime = Get-Date
Copy-Item $wslsettingsbinpath\wslsettings.dll $wslsettingsobjpath\wslsettings.dll -Force
Copy-Item $wslsettingsbinpath\wslsettings.exe $wslsettingsobjpath\apphost.exe -Force
- script: cmake --build . --config Release -- -m
displayName: "Build installer msix and tests (${{ platform }})"
- task: PowerShell@2
displayName: "Move ${{ platform }} installer msi to output directory"
inputs:
targetType: inline
script: |
New-Item -ItemType Directory -Path "$(ob_outputDirectory)\bundle" -Force
$arch = '${{ platform }}'
Copy-Item -Path "bin\$arch\release\wsl.msi" -Destination "$(ob_outputDirectory)\bundle\wsl.$(version.WSL_PACKAGE_VERSION).$arch.msi"
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@5
displayName: "Sign the bundle"
condition: and(succeeded(), eq('${{ parameters.isRelease }}', true))
inputs:
ConnectedServiceName: ${{ parameters.esrp.ConnectedServiceName}}
signConfigType: ${{ parameters.esrp.signConfigType }}
SessionTimeout: ${{ parameters.esrp.SessionTimeout }}
MaxConcurrency: ${{ parameters.esrp.MaxConcurrency }}
MaxRetryAttempts: ${{ parameters.esrp.MaxRetryAttempts }}
ServiceEndpointUrl: ${{ parameters.esrp.ServiceEndpointUrl }}
AuthAKVName: ${{ parameters.esrp.AuthAKVName }}
AuthSignCertName: ${{ parameters.esrp.AuthSignCertName }}
AppRegistrationClientId: ${{ parameters.esrp.AppRegistrationClientId }}
AppRegistrationTenantId: ${{ parameters.esrp.AppRegistrationTenantId }}
FolderPath: "bundle"
Pattern: "*.msixbundle"
UseMSIAuthentication: true
EsrpClientId: ${{ parameters.esrp.EsrpClientId }}
inlineOperation: |
[
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolSign",
"Parameters" : {
"OpusName" : "Microsoft",
"OpusInfo" : "http://www.microsoft.com",
"FileDigest" : "/fd \"SHA256\"",
"PageHash" : "/NPH",
"TimeStamp" : "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
},
"ToolName" : "sign",
"ToolVersion" : "1.0"
},
{
"KeyCode" : "CP-230012",
"OperationCode" : "SigntoolVerify",
"Parameters" : {},
"ToolName" : "sign",
"ToolVersion" : "1.0"
}
]
- script: md.exe $(ob_outputDirectory)\bin\nuget
displayName: "Create the nuget directory"
- ${{ each package in parameters.nugetPackages }}:
- script: nuget.exe pack ${{ package }} -OutputDirectory $(ob_outputDirectory)\bin\nuget -NonInteractive
displayName: Build ${{ package }}
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@5
displayName: "Sign nuget packages"
condition: and(succeeded(), eq('${{ parameters.isRelease }}', true))
inputs:
ConnectedServiceName: ${{ parameters.esrp.ConnectedServiceName}}
signConfigType: ${{ parameters.esrp.signConfigType }}
SessionTimeout: ${{ parameters.esrp.SessionTimeout }}
MaxConcurrency: ${{ parameters.esrp.MaxConcurrency }}
MaxRetryAttempts: ${{ parameters.esrp.MaxRetryAttempts }}
ServiceEndpointUrl: ${{ parameters.esrp.ServiceEndpointUrl }}
AuthAKVName: ${{ parameters.esrp.AuthAKVName }}
AuthSignCertName: ${{ parameters.esrp.AuthSignCertName }}
AppRegistrationClientId: ${{ parameters.esrp.AppRegistrationClientId }}
AppRegistrationTenantId: ${{ parameters.esrp.AppRegistrationTenantId }}
FolderPath: '$(ob_outputDirectory)\bin\nuget'
Pattern: "*.nupkg"
UseMSIAuthentication: true
EsrpClientId: ${{ parameters.esrp.EsrpClientId }}
inlineOperation: |
[
{
"KeyCode": "CP-401405",
"OperationCode": "NuGetSign",
"Parameters" : {},
"ToolName" : "sign",
"ToolVersion" : "1.0"
},
{
"KeyCode" : "CP-401405",
"OperationCode" : "NuGetVerify",
"Parameters" : {},
"ToolName" : "sign",
"ToolVersion" : "1.0"
}
]
- powershell: |
foreach ($arch in @("x64", "ARM64"))
{
$binFolder = ".\bin\$arch\Release"
$pdbFolder = Join-Path $(ob_outputDirectory) "pdb\$arch\Release"
mkdir $pdbFolder
foreach ($filter in @("*.pdb", "*.debug"))
{
foreach ($e in (Get-ChildItem -Recurse -Path $binFolder -Filter $filter)) {Copy-Item -Path $e.fullname -Destination (Join-Path $pdbFolder $e.name)}
}
}
displayName: Collect symbols
- powershell: |
mkdir appxsym
foreach ($arch in @("x64", "ARM64"))
{
Get-ChildItem -Path $(ob_outputDirectory)\pdb\$arch\release\*.pdb -Exclude wsltests.pdb | Compress-Archive -DestinationPath appxsym/Microsoft.WSL_$(version.WSL_PACKAGE_VERSION)_$arch.zip
Copy-Item -Path appxsym/Microsoft.WSL_$(version.WSL_PACKAGE_VERSION)_$arch.zip -Destination appxsym/Microsoft.WSL_$(version.WSL_PACKAGE_VERSION)_$arch.appxsym
}
mkdir $(ob_outputDirectory)/appxupload
Get-ChildItem -Path appxsym/*.appxsym,bundle/release/Microsoft.WSL_$(version.WSL_PACKAGE_VERSION)_x64_ARM64.msixbundle | Compress-Archive -DestinationPath $(ob_outputDirectory)/appxupload/Microsoft.WSL_$(version.WSL_PACKAGE_VERSION)_x64_ARM64.zip
Move-Item -Path $(ob_outputDirectory)/appxupload/Microsoft.WSL_$(version.WSL_PACKAGE_VERSION)_x64_ARM64.zip -Destination $(ob_outputDirectory)/appxupload/Microsoft.WSL_$(version.WSL_PACKAGE_VERSION)_x64_ARM64.appxupload
rm appxsym/*.appxsym
displayName: Create appxupload
condition: and(succeeded(), eq('${{ parameters.isRelease }}', true))
- powershell: |
$taefVersion = (Select-Xml -Path packages.config -XPath '/packages/package[@id=''Microsoft.Taef'']/@version').Node.Value
New-Item -ItemType Directory -Path "$(ob_outputDirectory)\bundle" -Force
foreach ($arch in @("x64", "ARM64"))
{
mkdir $(ob_outputDirectory)\testbin\$arch\release
Move-Item -Path "bin\$arch\release\wsltests.dll" -Destination "$(ob_outputDirectory)\testbin\$arch\release\wsltests.dll"
Move-Item -Path "bin\$arch\release\testplugin.dll" -Destination "$(ob_outputDirectory)\testbin\$arch\release\testplugin.dll"
Move-Item -Path "packages\Microsoft.Taef.$taefVersion\build\Binaries\$arch" -Destination "$(ob_outputDirectory)\testbin\$arch\release\taef"
}
Move-Item -Path "bin\x64\cloudtest" -Destination "$(ob_outputDirectory)\testbin\x64\cloudtest"
Move-Item -Path "tools\test\test-setup.ps1" -Destination "$(ob_outputDirectory)\testbin\test-setup.ps1"
Move-Item -Path "tools\test\CloudTest-Setup.bat" -Destination "$(ob_outputDirectory)\testbin\CloudTest-Setup.bat"
Move-Item -Path "tools\wsl.wprp" -Destination "$(ob_outputDirectory)\testbin\wsl.wprp"
Move-Item -Path "test\linux\unit_tests" -Destination "$(ob_outputDirectory)\testbin\unit_tests"
Move-Item -Path bundle\release\* -Destination $(ob_outputDirectory)\bundle
$TestDistroVersion = (Select-Xml -Path packages.config -XPath '/packages/package[@id=''Microsoft.WSL.TestDistro'']/@version').Node.Value
Copy-Item "packages\Microsoft.WSL.TestDistro.$TestDistroVersion\test_distro.tar.xz" "$(ob_outputDirectory)\testbin\x64"
displayName: Move artifacts to drop directory
- task: PublishSymbols@2
displayName: Publish symbols
inputs:
SymbolServerType: "TeamServices"
TreatNotIndexedAsWarning: true
SymbolsProduct: WSL
SymbolsVersion: $(version.WSL_PACKAGE_VERSION)
SearchPattern: |
$(ob_outputDirectory)/pdb/**/*.pdb
$(ob_outputDirectory)/bin/**/*.exe
$(ob_outputDirectory)/bin/**/*.dll
- task: CodeQL3000Finalize@0
condition: ${{ and(parameters.isNightly, eq(variables['Build.SourceBranch'], 'refs/heads/main'))}}

120
.pipelines/flight-stage.yml Normal file
View file

@ -0,0 +1,120 @@
parameters:
- name: publishPackage
type: boolean
default: false
- name: packageVersion
type: string
default: ''
- name: bypassTests
type: boolean
default: false
stages:
- stage: flight
${{ if eq(parameters.bypassTests, true) }}:
dependsOn: [build]
${{ else }}:
dependsOn: [test]
jobs:
- job: flight
displayName: 'Package and Flight WSL package'
dependsOn: [] # The stage handles this dependency
pool:
type: windows
variables:
AppId: 9P9TQF7MRM4R
FlightId: $(StoreBrokerFlightId)
StoreBrokerPath: $(Build.SourcesDirectory)\storebroker # location of StoreBroker information in the repo
StoreBrokerPayloadPath: $(Build.ArtifactStagingDirectory)\StoreBrokerPayload # location of package created for flight
WSL_PACKAGE_VERSION: $[ dependencies.build.outputs['version.WSL_PACKAGE_VERSION'] ]
ob_outputDirectory: '$(Build.SourcesDirectory)\out'
ob_artifactBaseName: 'drop_wsl'
ob_artifactSuffix: '_flight'
ob_sdl_checkcflags_enabled : false # Disable the CFLAGS check since we're not actually building anything in this stage
steps:
# Source: https://learn.microsoft.com/azure/devops/pipelines/build/run-retention?view=azure-devops&tabs=powershell
- task: PowerShell@2
condition: and(succeeded(), not(canceled()))
displayName: Retain this build
inputs:
failOnStderr: true
targetType: 'inline'
script: |
$contentType = "application/json";
$headers = @{ Authorization = 'Bearer $(System.AccessToken)' };
$rawRequest = @{ daysValid = 365 * 2; definitionId = $(System.DefinitionId); ownerId = 'User:$(Build.RequestedForId)'; protectPipeline = $false; runId = $(Build.BuildId) };
$request = ConvertTo-Json @($rawRequest);
$uri = "$(System.CollectionUri)$(System.TeamProject)/_apis/build/retention/leases?api-version=6.0-preview.1";
Invoke-RestMethod -uri $uri -method POST -Headers $headers -ContentType $contentType -Body $request;
# Download the build drop
- task: DownloadPipelineArtifact@2
displayName: Download Bundle artifact
inputs:
artifact: "drop_wsl_build"
path: drop
# copy the appxupload folder to the storebroker folder
- powershell: |
mkdir $(StoreBrokerPath)\appxpackage\
Copy-Item -Path drop\appxupload\* -Destination $(StoreBrokerPath)\appxpackage\ -Recurse -Force
displayName: Copy AppxUpload artifact
# creates a submission package that is published to the store; containers store page information and the WSL appxupload
- task: MS-RDX-MRO.windows-store-publish-dev.package-task.store-package@3
displayName: 'Creating StoreBroker Payload'
inputs:
serviceEndpoint: 'AzureConnection-StoreBroker-WIF'
sbConfigPath: $(StoreBrokerPath)\sbconfig.json
sourceFolder: $(StoreBrokerPath)\appxpackage\
contents: Microsoft.WSL_${{ parameters.packageVersion }}.0_x64_ARM64.appxupload
pdpPath: $(StoreBrokerPath)\PDPs\
pdpInclude: PDP.xml
pdpMediaPath: $(StoreBrokerPath)\Media\
outSBPackagePath: $(StoreBrokerPayloadPath)
outSBName: WindowsSubsystemForLinux
# copy the storebroker submission package to the drop folder so it can be used if needed
- powershell: |
New-Item -ItemType Directory -Force -Path $(ob_outputDirectory)
Copy-Item -Path $(StoreBrokerPayloadPath)\* -Destination $(ob_outputDirectory) -Recurse -Force
Copy-Item -Path SBLog.txt -Destination $(ob_outputDirectory) -Force
displayName: Copy StoreBrokerPayload to drop
# submit the package flight to the WSL SelfHost Flight Group
- task: MS-RDX-MRO.windows-store-publish-dev.flight-task.store-flight@3
displayName: 'Flight StoreBroker Package to Partner Center - WSL SelfHost Flight Group'
condition: and(succeeded(), eq('${{ parameters.publishPackage }}', true))
inputs:
serviceEndpoint: 'AzureConnection-StoreBroker-WIF'
appId: $(AppId)
flightId: $(FlightId)
inputMethod: JsonAndZip
jsonPath: $(StoreBrokerPayloadPath)\WindowsSubsystemForLinux.json
zipPath: $(StoreBrokerPayloadPath)\WindowsSubsystemForLinux.zip
force: true
skipPolling: true # skips polling Partner Centre/store API for the state of the package; skipping will mean that errors in the process will only show up in Partner Center
targetPublishMode: Immediate # on completion of this task, the package will be published to the WSL SelfHost flight once ceritified (no manual clicking of any buttons in Partner Center)
preserveSubmissionId: false
deletePackages: true
numberOfPackagesToKeep: 0
- task: PipAuthenticate@1
displayName: 'Pip Authenticate'
inputs:
artifactFeeds: 'wsl'
# Create a draft github release
- powershell: |
pip install --user -r tools/devops/requirements.txt
python tools/devops/create-release.py '${{ parameters.packageVersion }}' drop\bundle\Microsoft.WSL_${{ parameters.packageVersion }}.0_x64_ARM64.msixbundle drop\bundle\wsl.${{ parameters.packageVersion }}.0.arm64.msi drop\bundle\wsl.${{ parameters.packageVersion }}.0.x64.msi --no-fetch --github-token "$env:token" ${{ iif(parameters.publishPackage, '--publish', '--use-current-ref') }}
displayName: Create Github release
env:
token: $(GITHUB_RELEASE_TOKEN)

View file

@ -0,0 +1,48 @@
parameters:
- name: isNightly
type: boolean
default: false
- name: nugetPackages
type: object
default:
- Microsoft.WSL.PluginApi
stages:
- stage: nuget
dependsOn: [build, test]
jobs:
- job: nuget
displayName: 'Publish nuget packages'
condition: and(succeeded(), or(eq(variables['Build.Reason'], 'Schedule'), eq('${{ parameters.isNightly }}', false)))
dependsOn: [] # The stage handles this dependency
pool:
type: windows
variables:
WSL_NUGET_PACKAGE_VERSION: $[ dependencies.build.outputs['version.WSL_NUGET_PACKAGE_VERSION'] ]
NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS: 60
NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS: 60
ob_outputDirectory: '$(Build.SourcesDirectory)\out'
ob_artifactBaseName: 'drop_wsl'
ob_artifactSuffix: '_nuget'
steps:
- task: DownloadPipelineArtifact@2
displayName: Download nuget artifacts
inputs:
artifact: "drop_wsl_build"
path: drop
# Note: this task might fail if there's been no commits between two nightly pipelines, which is fine.
- ${{ each package in parameters.nugetPackages }}:
- task: NuGetCommand@2
displayName: Push nuget/${{ package }}.$(WSL_NUGET_PACKAGE_VERSION).nupkg
inputs:
command: 'push'
packagesToPush: drop/nuget/${{ package }}.$(WSL_NUGET_PACKAGE_VERSION).nupkg
nuGetFeedType: 'internal'
publishVstsFeed: wsl
allowPackageConflicts: ${{ parameters.isNightly }}

42
.pipelines/test-job.yml Normal file
View file

@ -0,0 +1,42 @@
parameters:
- name: branch
type: string
- name: version
type: string
- name: image
type: string
- name: run
type: boolean
jobs:
- job: test_${{ parameters.branch }}_${{ parameters.version }}
displayName: "${{ parameters.version }} tests - ${{ parameters.branch }}"
dependsOn: []
condition: and(succeeded(), eq('${{ parameters.run }}', true))
variables:
ob_outputDirectory: '$(Build.SourcesDirectory)\out'
ob_artifactBaseName: 'drop_wsl'
ob_artifactSuffix: '_test'
timeoutInMinutes: 360
cancelTimeoutInMinutes: 420
pool:
type: cloudtestagentless
steps:
- task: CloudTestServerBuildTask@2
inputs:
DisplayName: "${{ parameters.version }} tests - ${{ parameters.branch }}"
connectedServiceName: "CloudTest-PROD"
cloudTestTenant: "wsl"
testMapLocation: 'testbin\x64\cloudtest\wsl-test-image-${{ parameters.image }}-${{ parameters.version}}\TestMap.xml'
pipelineArtifactName: "drop_wsl_build"
pipelineArtifactBuildUrl: '$(System.TaskDefinitionsUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)'
buildDropArtifactName: ""
timeoutInMinutes: 360
cancelTimeoutInMinutes: 420
TestTimeout: "0.05:00:00"
parserProperties: "worker:VsTestVersion=V150;session:HoldTrigger=Failure;VstsTestResultAttachmentUploadBehavior=Always"
notificationSubscribers: $(Build.RequestedForEmail)
scheduleBuildRequesterAlias: "lowdev"

37
.pipelines/test-stage.yml Normal file
View file

@ -0,0 +1,37 @@
parameters:
- name: rs_prerelease_only
type: boolean
default: false
- name: versions
type: object
default:
- wsl1
- wsl2
- name: test_images
type: object
default:
- name: rs_prerelease
image: rs_prerelease-2025-01-30
- name: ni_release
image: win11-23h2-ent-2024-11-18
- name: fe_release
image: 2022-datacenter-g2-2024-09-10
- name: vb_release
image: win10-22h2-ent-g2-2024-09-10
# TODO: ge_release
stages:
- stage: test
dependsOn: [build]
jobs:
- ${{ each version in parameters.versions }}:
- ${{ each image in parameters.test_images }}:
- template: test-job.yml@self
parameters:
branch: "${{ image.name }}"
version: ${{ version }}
image: "${{ image.image }}"
run: ${{ or(not(parameters.rs_prerelease_only), eq(image.name, 'rs_prerelease')) }}

View file

@ -0,0 +1,53 @@
trigger:
branches:
include:
- main
paths:
include:
- 'localization/strings/en-US/Resources.resw'
# Schedule nightly build
# Cron syntax: "mm HH DD MM DW" = minutes, hours, days, months, day of week (UTC time)
schedules:
# "0 8" = 8AM UTC = 12AM PST
- cron: "0 8 * * *"
displayName: Nightly Touchdown Build Schedule
branches:
include:
- "main"
always: true
pool:
name: 'wsl-build'
steps:
- checkout : self
persistCredentials: true
- task: TouchdownBuildTask@4
displayName: Touchdown Build Localization
inputs:
environment: 'PRODEXT'
teamId: '38646'
authType: 'FederatedIdentity'
FederatedIdentityServiceConnection: 'Azure-Connection'
isPreview: false
resourceFilePath: |
localization\strings\en-US\Resources.resw;O:localization\strings\
storebroker\PDPs\en-us\PDP.xml;O:storebroker\PDPs\
localizationTarget: true
pseudoSetting: 'Excluded'
cultureMappingType: 'None'
- task: PipAuthenticate@1
inputs:
artifactFeeds: 'wsl'
- powershell: |
pip install --user -r tools/devops/requirements.txt
python tools/devops/create-change.py . "$env:token" "WSL localization" "Localization change from build: $env:buildId" "user/localization/$env:buildId"
displayName: Create pull request
env:
token: $(GithubPRToken)
buildId: $(Build.BuildId)

View file

@ -0,0 +1,50 @@
trigger: none
schedules:
# "0 8" = 8AM UTC = 12AM PST
- cron: "0 8 * * *"
displayName: Nightly build
branches:
include: [main]
always: true
variables:
WindowsContainerImage: "onebranch.azurecr.io/windows/ltsc2022/vse2022:latest"
WindowsHostVersion: '1ESWindows2022'
resources:
repositories:
- repository: templates
type: git
name: OneBranch.Pipelines/GovernedTemplates
ref: refs/heads/main
extends:
template: v2/Microsoft.NonOfficial.yml@templates
parameters:
platform:
name: "windows_undocked"
featureFlags:
EnableCDPxPAT: false
WindowsHostVersion: 1ESWindows2022
globalSdl:
credscan:
enabled: true
perStage:
credscan:
enabled: true
tsa:
enabled: false
git:
fetchDepth: -1
fetchTags: true
stages:
- template: build-stage.yml@self
parameters:
isRelease: false
isNightly: true
- template: test-stage.yml@self
parameters:
rs_prerelease_only: false

View file

@ -0,0 +1,33 @@
trigger:
branches:
include:
- main
pool:
name: 'wsl-build'
steps:
- checkout : self
persistCredentials: true
- task: ComponentGovernanceComponentDetection@0
displayName: Component Detection
- task: notice@0
displayName: Generate NOTICE file
inputs:
outputfile: $(System.DefaultWorkingDirectory)/NOTICE.txt
outputformat: text
- task: PipAuthenticate@1
inputs:
artifactFeeds: 'wsl'
- powershell: |
pip install --user -r tools/devops/requirements.txt
python tools/devops/create-change.py . "$env:token" "WSL notice" "Notice change from build: $env:buildId" "user/notice/$env:buildId"
displayName: Create pull request
env:
token: $(GithubPRToken)
buildId: $(Build.BuildId)

View file

@ -0,0 +1,52 @@
trigger:
branches:
include:
- main
- release/*
variables:
WindowsContainerImage: "onebranch.azurecr.io/windows/ltsc2022/vse2022:latest"
WindowsHostVersion: '1ESWindows2022'
resources:
repositories:
- repository: templates
type: git
name: OneBranch.Pipelines/GovernedTemplates
ref: refs/heads/main
extends:
template: v2/Microsoft.NonOfficial.yml@templates
parameters:
platform:
name: "windows_undocked"
featureFlags:
EnableCDPxPAT: false
WindowsHostVersion: 1ESWindows2022
globalSdl:
suppression:
suppressionFile: $(Build.SourcesDirectory)\.gdnsuppress
suppressionSet: default
apiscan:
enabled: false
credscan:
enabled: true
perStage:
credscan:
enabled: true
policheck:
enabled: true
break: true
severity: Note
git:
fetchDepth: -1
fetchTags: true
stages:
- template: build-stage.yml@self
parameters:
isRelease: false
- template: test-stage.yml@self
parameters:
rs_prerelease_only: true

View file

@ -0,0 +1,69 @@
parameters:
- name: bypassTests
displayName: 'Publish release even if tests fail'
type: boolean
default: false
- name: testVersion
displayName: 'Test the release pipeline'
type: string
default: ''
trigger:
tags:
include: ['*.*.*']
variables:
WindowsContainerImage: "onebranch.azurecr.io/windows/ltsc2022/vse2022:latest"
WindowsHostVersion: '1ESWindows2022'
resources:
repositories:
- repository: templates
type: git
name: OneBranch.Pipelines/GovernedTemplates
ref: refs/heads/main
extends:
template: v2/Microsoft.Official.yml@templates
parameters:
platform:
name: "windows_undocked"
featureFlags:
EnableCDPxPAT: false
WindowsHostVersion: 1ESWindows2022
globalSdl:
credscan:
enabled: true
perStage:
credscan:
enabled: true
tsa:
enabled: false
evidence:
enabled: false
git:
fetchDepth: -1
fetchTags: true
stages:
- template: build-stage.yml@self
parameters:
isRelease: true
packageVersion: ${{ iif(eq(parameters.testVersion, ''), variables['Build.SourceBranchName'], parameters.testVersion) }}
traceLoggingConfig: $(ReleaseTraceLoggingConfig)
- template: test-stage.yml@self
parameters:
rs_prerelease_only: false
- template: flight-stage.yml@self
parameters:
publishPackage: ${{ iif(eq(parameters.testVersion, ''), true, false) }}
packageVersion: ${{ iif(eq(parameters.testVersion, ''), variables['Build.SourceBranchName'], parameters.testVersion) }}
bypassTests: ${{ parameters.bypassTests }}
- ${{ if eq(parameters.testVersion, '') }}:
- template: nuget-stage.yml@self
parameters:
isNightly: false

445
CMakeLists.txt Normal file
View file

@ -0,0 +1,445 @@
cmake_minimum_required(VERSION 3.25)
set(CMAKE_SYSTEM_VERSION 10.0.26100.0)
project(wsl)
# Rationalize TARGET_PLATFORM
if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "arm64" OR "${TARGET_PLATFORM}" STREQUAL "arm64")
set(TARGET_PLATFORM "arm64")
set(TEST_DISTRO_PLATFORM "arm64")
elseif("${CMAKE_GENERATOR_PLATFORM}" MATCHES "x64|amd64|" OR "${TARGET_PLATFORM}" MATCHES "x64|amd64|")
set(TARGET_PLATFORM "x64")
set(TEST_DISTRO_PLATFORM "amd64")
else()
message(FATAL_ERROR "Unsupported platform: ${CMAKE_GENERATOR_PLATFORM}")
endif()
if (NOT ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} STREQUAL ${CMAKE_SYSTEM_VERSION})
message(FATAL_ERROR "Incorrect Windows SDK version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}, requires ${CMAKE_SYSTEM_VERSION}")
endif()
include(FetchContent)
# Import GSL and nlohmannjson
set(FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/_deps/${TARGET_PLATFORM})
FetchContent_Declare(GSL
URL https://github.com/microsoft/GSL/archive/refs/tags/v4.0.0.tar.gz
URL_HASH SHA256=f0e32cb10654fea91ad56bde89170d78cfbf4363ee0b01d8f097de2ba49f6ce9)
FetchContent_MakeAvailable(GSL)
FetchContent_GetProperties(GSL SOURCE_DIR GSL_SOURCE_DIR)
FetchContent_Declare(nlohmannjson
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
URL_HASH SHA256=d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d)
FetchContent_MakeAvailable(nlohmannjson)
FetchContent_GetProperties(nlohmannjson SOURCE_DIR NLOHMAN_JSON_SOURCE_DIR)
# Import modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(IDL REQUIRED)
find_package(LINUXBUILD REQUIRED)
find_package(NUGET REQUIRED)
find_package(VERSION REQUIRED)
find_package(MC REQUIRED)
find_package(Appx REQUIRED)
# Download nuget packages
restore_nuget_packages()
# Load nuget packages versions and paths
parse_nuget_packages_versions()
find_nuget_package(Microsoft.Direct3D.Linux DIRECT3D /build/native)
find_nuget_package(Microsoft.Identity.MSAL.WSL.Proxy MSAL /build/native/bin)
find_nuget_package(Microsoft.RemoteDesktop.Client.MSRDC.SessionHost MSRDC /build/native/bin)
find_nuget_package(Microsoft.Taef TAEF /)
find_nuget_package(Microsoft.Windows.ImplementationLibrary WIL /)
find_nuget_package(Microsoft.WSL.DeviceHost WSL_DEVICE_HOST /build/native)
find_nuget_package(Microsoft.WSL.Kernel KERNEL /build/native)
find_nuget_package(Microsoft.WSL.bsdtar BSDTARD /build/native/bin)
find_nuget_package(Microsoft.WSL.LinuxSdk LINUXSDK /)
find_nuget_package(Microsoft.WSL.TestDistro TEST_DISTRO /)
find_nuget_package(Microsoft.WSLg WSLG /build/native/bin)
find_nuget_package(StrawberryPerl PERL /)
find_nuget_package(vswhere VSWHERE /tools)
find_nuget_package(Wix WIX /tools/net6.0/any)
# Architecture-specific nuget packages from the OS repo.
if (${TARGET_PLATFORM} STREQUAL "x64")
find_nuget_package(Microsoft.DXCore.Linux.amd64fre DXCORE /build/native)
find_nuget_package(Microsoft.WSL.Dependencies.amd64fre WSLDEPS /build/native)
find_nuget_package(Microsoft.WSL.LxUtil.amd64fre LXUTIL /build/native)
endif()
if (${TARGET_PLATFORM} STREQUAL "arm64")
find_nuget_package(Microsoft.DXCore.Linux.arm64fre DXCORE /build/native)
find_nuget_package(Microsoft.WSL.Dependencies.arm64fre WSLDEPS /build/native)
find_nuget_package(Microsoft.WSL.LxUtil.arm64fre LXUTIL /build/native)
endif()
# Wsl Settings packages
find_nuget_package(CommunityToolkit.Mvvm CTK_MVVM /)
find_nuget_package(CommunityToolkit.WinUI.Animations CTK_ANIMATIONS /)
find_nuget_package(CommunityToolkit.WinUI.Controls.SettingsControls CTK_STTNGS_CTRLS /)
find_nuget_package(Microsoft.Extensions.Hosting EXTS_HOSTING /)
find_nuget_package(Microsoft.NETCore.App.Runtime.win-${TARGET_PLATFORM} DOTNET_RUNTIME /)
find_nuget_package(Microsoft.WindowsAppSDK WIN_APP_SDK /)
find_nuget_package(Microsoft.Windows.SDK.NET.Ref WINDOWS_SDK_DOTNET /)
find_nuget_package(Microsoft.Xaml.Behaviors.WinUI.Managed XAML_BEHAVIORS /)
find_nuget_package(WinUIEx WINUIEX /)
set(BIN2CPIO ${CMAKE_CURRENT_LIST_DIR}/tools/bin2cpio/bin2cpio.pl)
set(WSLG_TS_PLUGIN_DLL "WSLDVCPlugin.dll")
# Default to debug build if unspecified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
set(SUPPORTED_LANGS cs-CZ;da-DK;de-DE;en-GB;en-US;es-ES;fi-FI;fr-FR;hu-HU;it-IT;ja-JP;ko-KR;nb-NO;nl-NL;pl-PL;pt-BR;pt-PT;ru-RU;sv-SE;tr-TR;zh-CN;zh-TW)
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/UserConfig.cmake")
find_package(USER REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR})
endif()
# Optional target configuration
if (NOT DEFINED WSL_BUILD_WSL_SETTINGS)
set(WSL_BUILD_WSL_SETTINGS true)
endif ()
# Only generate the build configuration that CMake is configured for
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}" CACHE STRING "" FORCE)
find_commit_hash(COMMIT_HASH)
if (NOT PACKAGE_VERSION)
find_version(PACKAGE_VERSION WSL_NUGET_PACKAGE_VERSION) # Fetch the package version from git if not specified
endif ()
if (NOT PACKAGE_VERSION MATCHES "^([0-9]+).([0-9]+).([0-9]+).([0-9]+)$")
message(FATAL_ERROR "PACKAGE_VERSION is invalid: '${PACKAGE_VERSION}'. Needs to match '([0-9]+).([0-9]+).([0-9]+).([0-9]+)'")
endif()
set(PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
set(PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
set(PACKAGE_VERSION_REVISION ${CMAKE_MATCH_3})
# The store requires the revision number to be 0, so enforce this on official builds
if (OFFICIAL_BUILD AND NOT PACKAGE_VERSION MATCHES "^([0-9]+).([0-9]+).([0-9]+).0$")
message(FATAL_ERROR "PACKAGE_VERSION is invalid: '${PACKAGE_VERSION}'. Needs to match '([0-9]+).([0-9]+).([0-9]+).0' for official builds")
endif()
# Configure output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${TARGET_PLATFORM})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Packaging variables
set(BIN ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE})
file(MAKE_DIRECTORY ${BIN})
set (GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
file(MAKE_DIRECTORY ${GENERATED_DIR})
set(PACKAGE_CERTIFICATE ${GENERATED_DIR}/dev-cert.pfx)
file(CREATE_LINK ${WSL_DEVICE_HOST_SOURCE_DIR}/bin/${TARGET_PLATFORM}/wsldevicehost.dll ${BIN}/wsldevicehost.dll)
file(CREATE_LINK ${LXUTIL_SOURCE_DIR}/bin/lxutil.dll ${BIN}/lxutil.dll)
file(CREATE_LINK ${WSLG_SOURCE_DIR}/${TARGET_PLATFORM}/${WSLG_TS_PLUGIN_DLL} ${BIN}/${WSLG_TS_PLUGIN_DLL})
file(CREATE_LINK ${WSLDEPS_SOURCE_DIR}/bin/wsldeps.dll ${BIN}/wsldeps.dll)
if (${SKIP_PACKAGE_SIGNING})
set(PACKAGE_SIGN_COMMAND echo Skipped package signing for:)
else()
if (NOT EXISTS ${PACKAGE_CERTIFICATE})
execute_process(
COMMAND powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive ${CMAKE_CURRENT_LIST_DIR}/tools/create-dev-cert.ps1 -OutputPath ${PACKAGE_CERTIFICATE}
COMMAND_ERROR_IS_FATAL ANY)
endif()
set(PACKAGE_SIGN_COMMAND SignTool.exe sign /a /v /fd SHA256 /f ${PACKAGE_CERTIFICATE})
endif()
# Generate local test script
configure_file(${CMAKE_CURRENT_LIST_DIR}/tools/test/test.bat.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/test.bat)
# Common build flags
set(CMAKE_CXX_STANDARD 20)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif()
if (${TARGET_PLATFORM} STREQUAL "x64")
add_compile_definitions(_AMD64_)
endif()
if (${TARGET_PLATFORM} STREQUAL "arm64")
add_compile_definitions(_ARM64_)
endif()
add_definitions(/sdl) # Default-initialize class members
add_definitions(/FS) # Enable parallel PDB access
add_compile_definitions(UNICODE
WIL_SUPPRESS_PRIVATE_API_USE
CPPWINRT_SUPPRESS_STATIC_INITIALIZERS
NOMINMAX
_CRT_SECURE_NO_WARNINGS
KERNEL_VERSION="${KERNEL_VERSION}"
WSLDEPS_VERSION="${WSLDEPS_VERSION}"
WSLG_VERSION="${WSLG_VERSION}"
WSLG_TS_PLUGIN_DLL=L"${WSLG_TS_PLUGIN_DLL}"
WSL_DEVICE_HOST_VERSION="${WSL_DEVICE_HOST_VERSION}"
COMMIT_HASH="${COMMIT_HASH}"
WSL_PACKAGE_VERSION="${PACKAGE_VERSION}"
LXUTIL_VERSION="${LXUTIL_VERSION}"
MSRDC_VERSION="${MSRDC_VERSION}"
DIRECT3D_VERSION="${DIRECT3D_VERSION}"
DXCORE_VERSION="${DXCORE_VERSION}"
WSL_PACKAGE_VERSION_MAJOR=${PACKAGE_VERSION_MAJOR}
WSL_PACKAGE_VERSION_MINOR=${PACKAGE_VERSION_MINOR}
WSL_PACKAGE_VERSION_REVISION=${PACKAGE_VERSION_REVISION}
WSL_BUILD_WSL_SETTINGS=${WSL_BUILD_WSL_SETTINGS})
if (${OFFICIAL_BUILD})
add_compile_definitions(WSL_OFFICIAL_BUILD)
endif()
if (${WSL_BUILD_THIN_PACKAGE})
add_compile_definitions(WSL_DEV_THIN_MSI_PACKAGE="${BIN}/wsl.msi")
endif ()
string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) # make sure /Zi is removed from the debug flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /W3 /WX /ZH:SHA_256")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7 -DDEBUG -DDBG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /guard:cf /Qspectre")
# Linker flags
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /debug:full /debugtype:cv,fixup /guard:cf /DYNAMICBASE")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /debug:full /debugtype:cv,fixup /guard:cf /DYNAMICBASE")
if (${TARGET_PLATFORM} STREQUAL "x64")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /CETCOMPAT")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /CETCOMPAT")
endif()
# Common link libraries
link_directories(${WSLDEPS_SOURCE_DIR}/lib/)
link_directories(${LXUTIL_SOURCE_DIR}/lib/)
set(COMMON_LINK_LIBRARIES
ws2_32.lib
Userenv.lib
RuntimeObject.lib
Pathcch.lib
ntdll.lib
RpcRT4.lib
Mswsock.lib
Shlwapi.lib
synchronization.lib
Bcrypt.lib
Iphlpapi.lib
icu.lib
computecore.lib
computenetwork.lib
MI.lib
Wintrust.lib
msi.lib
wsldeps.lib)
# Linux
if(${TARGET_PLATFORM} STREQUAL "" OR ${TARGET_PLATFORM} STREQUAL "x64")
set(LLVM_ARCH x86_64)
elseif(${TARGET_PLATFORM} STREQUAL "arm64")
set(LLVM_ARCH aarch64)
else()
message(FATAL_ERROR "Unsupported platform: '${TARGET_PLATFORM}'")
endif()
# Determine the Visual Studio installation directory which contains LLVM tools
execute_process(
COMMAND "${VSWHERE_SOURCE_DIR}/vswhere.exe" -latest -products * -property installationPath
OUTPUT_VARIABLE VS_INSTALL_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY
)
if (NOT VS_INSTALL_DIR)
message(FATAL_ERROR "Could not determine Visual Studio installation directory.")
endif()
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
set(LLVM_INSTALL_DIR "${VS_INSTALL_DIR}/VC/Tools/Llvm/x64/bin")
else()
set(LLVM_INSTALL_DIR "${VS_INSTALL_DIR}/VC/Tools/Llvm/${CMAKE_HOST_SYSTEM_PROCESSOR}/bin")
endif()
if (NOT EXISTS ${LLVM_INSTALL_DIR})
message(FATAL_ERROR "C++ Clang Compiler for Windows is not installed. Please install it from the Visual Studio Installer.")
endif()
# Generate the clang-format script which contains a path to clang-format.exe
configure_file(${CMAKE_CURRENT_LIST_DIR}/tools/FormatSource.ps1.in ${CMAKE_BINARY_DIR}/FormatSource.ps1)
cmake_path(COMPARE "${wsl_SOURCE_DIR}" EQUAL "${wsl_BINARY_DIR}" BUILD_IN_SOURCE)
if (NOT ${BUILD_IN_SOURCE}) # Testing on 3.26 project_type_DIR paths appear canonicalized
file(CREATE_LINK ${LLVM_INSTALL_DIR}/clang-format.exe ${wsl_SOURCE_DIR}/tools/clang-format.exe COPY_ON_ERROR)
endif()
set(LINUXSDK_PATH ${LINUXSDK_SOURCE_DIR}/${LLVM_ARCH})
set(LLVM_TARGET "${LLVM_ARCH}-unknown-linux-musl")
set(LINUX_CC ${LLVM_INSTALL_DIR}/clang.exe)
set(LINUX_CXX ${LLVM_INSTALL_DIR}/clang++.exe)
set(LINUX_AR ${LLVM_INSTALL_DIR}/llvm-ar.exe)
set(LINUX_COMMON_FLAGS --gcc-toolchain=${LINUXSDK_PATH}
-fpic
-B${LINUXSDK_PATH}
-isysroot ${LINUXSDK_PATH}
-isystem ${LINUXSDK_PATH}/include/c++/v1
-isystem ${LINUXSDK_PATH}/include
-isystem ${GSL_SOURCE_DIR}/include
-isystem "${WSLDEPS_SOURCE_DIR}/include/lxcore"
-isystem "${WSLDEPS_SOURCE_DIR}/include/schemas"
-I "${CMAKE_CURRENT_LIST_DIR}/src/linux/inc"
-I "${CMAKE_CURRENT_LIST_DIR}/src/linux/mountutil"
-I "${CMAKE_CURRENT_LIST_DIR}/src/linux/plan9"
-I "${CMAKE_CURRENT_LIST_DIR}/src/shared/configfile"
-I "${CMAKE_CURRENT_LIST_DIR}/src/shared/inc"
-I "${NLOHMAN_JSON_SOURCE_DIR}/include"
-I "${CMAKE_BINARY_DIR}/generated"
--no-standard-libraries
-Werror
-Wall
-Wpointer-arith
-D_POSIX_C_SOURCE=200809L
-Dswprintf_s=swprintf
-fms-extensions
-target ${LLVM_TARGET}
-D_GNU_SOURCE=1
-D_LARGEFILE64_SOURCE
-DWSL_PACKAGE_VERSION="${PACKAGE_VERSION}"
-DWSL_PACKAGE_VERSION_MAJOR=${PACKAGE_VERSION_MAJOR}
-DWSL_PACKAGE_VERSION_MINOR=${PACKAGE_VERSION_MINOR}
-DWSL_PACKAGE_VERSION_REVISION=${PACKAGE_VERSION_REVISION}
)
if (${TARGET_PLATFORM} STREQUAL "x64")
set(LINUX_COMMON_FLAGS ${LINUX_COMMON_FLAGS} -D_AMD64_)
endif()
if (${TARGET_PLATFORM} STREQUAL "arm64")
set(LINUX_COMMON_FLAGS ${LINUX_COMMON_FLAGS} -D_ARM64_)
endif()
set(LINUX_CXXFLAGS ${LINUX_COMMON_FLAGS} -std=c++20)
set(LINUX_CFLAGS ${LINUX_COMMON_FLAGS} -std=c99)
string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
if (build_type STREQUAL debug)
set(LINUX_BUILD_TYPE_FLAGS -g3 -fno-inline-functions -DDEBUG -DDBG)
else()
set(LINUX_BUILD_TYPE_FLAGS -g -O2 -DNDEBUG)
endif()
set(LINUX_LDFLAGS -target ${LLVM_TARGET}
--gcc-toolchain=${LINUXSDK_PATH}
-B${LINUXSDK_PATH}
-isysroot ${LINUXSDK_PATH}
-nostartfiles
--no-standard-libraries
-fuse-ld=lld.exe
-L${LINUXSDK_PATH}/lib
-L${LINUXSDK_PATH}/lib/linux
-L${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}
-lclang_rt.builtins-${LLVM_ARCH}
-l:libc.a
-static)
set(COMMON_LINUX_LINK_LIBRAIRIES configfile)
if(DEFINED ENV{WSL_DEV_BINARY_PATH})
set(WSL_DEV_BINARY_PATH $ENV{WSL_DEV_BINARY_PATH})
endif()
if (DEFINED WSL_DEV_BINARY_PATH) # Development shortcut to make the package smaller
add_compile_definitions(WSL_SYSTEM_DISTRO_PATH="${WSL_DEV_BINARY_PATH}/system.vhd"
WSL_KERNEL_PATH="${WSL_DEV_BINARY_PATH}/kernel"
WSL_KERNEL_MODULES_PATH="${WSL_DEV_BINARY_PATH}/modules.vhd"
WSL_DEV_INSTALL_PATH="${WSL_DEV_BINARY_PATH}"
WSL_GPU_LIB_PATH="${WSL_DEV_BINARY_PATH}/lib")
endif()
# Common include paths
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wil/include)
include_directories(${WSLDEPS_SOURCE_DIR}/include)
include_directories(${WSLDEPS_SOURCE_DIR}/include/Windows)
include_directories(${WSLDEPS_SOURCE_DIR}/include/schemas)
include_directories(${WSLDEPS_SOURCE_DIR}/include/lxcore)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/shared/inc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/windows/inc)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/windows/service/inc/${TARGET_PLATFORM}/${CMAKE_BUILD_TYPE})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/windows/wslinstaller/inc/${TARGET_PLATFORM}/${CMAKE_BUILD_TYPE})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/linux/init/inc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/windows/common)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/shared/configfile)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/localization)
include_directories(${CMAKE_BINARY_DIR}/generated)
include_directories(${WIL_SOURCE_DIR}/include)
include_directories(${GSL_SOURCE_DIR}/include)
include_directories(${TAEF_SOURCE_DIR}/build/include)
include_directories(${NLOHMAN_JSON_SOURCE_DIR}/include)
link_directories(${TAEF_SOURCE_DIR}/build/Library/${TARGET_PLATFORM})
set(TAEF_LINK_LIBRARIES
TE.Common.lib
Wex.Common.lib
Wex.Logger.lib)
# Subprojects
add_subdirectory(nuget)
add_subdirectory(msixgluepackage)
add_subdirectory(msipackage)
add_subdirectory(msixinstaller)
add_subdirectory(src/windows/common)
add_subdirectory(src/windows/service)
add_subdirectory(src/windows/wslinstaller/inc)
add_subdirectory(src/windows/wslinstaller/stub)
add_subdirectory(src/windows/wslinstaller/exe)
add_subdirectory(src/shared/configfile)
add_subdirectory(src/windows/wsl)
add_subdirectory(src/windows/wslg)
add_subdirectory(src/windows/wslhost)
add_subdirectory(src/windows/wslrelay)
add_subdirectory(src/windows/wslinstall)
if (WSL_BUILD_WSL_SETTINGS)
add_subdirectory(src/windows/libwsl)
add_subdirectory(src/windows/wslsettings)
endif()
add_subdirectory(src/linux/netlinkutil)
add_subdirectory(src/linux/mountutil)
add_subdirectory(src/linux/plan9)
add_subdirectory(src/linux/init)
add_subdirectory(localization)
add_subdirectory(test/windows)
if (DEFINED PIPELINE_BUILD_ID)
add_subdirectory(cloudtest)
endif()
if(DEFINED ENV{WSL_POST_BUILD_COMMAND})
set(WSL_POST_BUILD_COMMAND $ENV{WSL_POST_BUILD_COMMAND})
endif ()

View file

@ -1,123 +1,44 @@
Please provide as much information as possible when reporting a bug or filing an issue on the Windows Subsystem for Linux.
# WSL contributing guide
## Important: Reporting BSODs and Security issues
There are a few main ways to contribute to WSL, with guides to each one:
1. [Add a feature or bugfix to WSL](#add-a-feature-or-bugfix-to-wsl)
2. [File a WSL issue](#file-a-wsl-issue)
## Add a feature or bugfix to WSL
We welcome any contributions to the WSL source code to add features or fix bugs! Before you start actually working on the feature, please **[file it as an issue, or a feature request in this repository](https://github.com/microsoft/WSL/issues)** so that we can track it and provide any feedback if necessary.
Once you have done so, please see [the developer docs](./doc/docs/dev-loop.md) for instructions on how to build WSL locally on your machine for development.
When your fix is ready, please [submit it as a pull request in this repository](https://github.com/microsoft/WSL/pulls) and the WSL team will triage and respond to it. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
## File a WSL issue
You can file issues for WSL at the WSL repository, or linked repositories. Before filing an issue please search for any existing issues and upvote or comment on those if possible.
1. If your issue is related to WSL documentation, please file it at [microsoftdocs/wsl](https://github.com/microsoftdocs/WSL/issues)
2. If your issue is related to a Linux GUI app, please file it at [microsoft/wslg](https://github.com/microsoft/wslg/issues)
3. Otherwise if you have a technical issue related to WSL in general, such as start up issues, etc., please file it at [microsoft/wsl](https://github.com/microsoft/WSL/issues)
Please provide as much information as possible when reporting a bug or filing an issue on the Windows Subsystem for Linux, and be sure to include logs as necessary!
Please see the [notes for collecting WSL logs](#notes-for-collecting-wsl-logs) section below for more info on filing issues.
## Thank you
Thank you in advance for your contribution! We appreciate your help in making WSL a better tool for everyone.
## Notes for collecting WSL logs
### Important: Reporting BSODs and Security issues
**Do not open GitHub issues for Windows crashes (BSODs) or security issues.**. Instead, send Windows crashes or other security-related issues to secure@microsoft.com.
See the `10) Reporting a Windows crash (BSOD)` section below for detailed instructions.
## Reporting issues in Windows Console or WSL text rendering/user experience
### Reporting issues in Windows Console or WSL text rendering/user experience
Note that WSL distro's launch in the Windows Console (unless you have taken steps to launch a 3rd party console/terminal). Therefore, *please file UI/UX related issues in the [Windows Console issue tracker](https://github.com/microsoft/console)*.
## Reporting issues in WSL
A well written bug report will follow the following template:
### 1) Issue Title
A title succinctly describing the issue.
#### Example:
`Traceroute not working.`
### 2) Windows version / build number
Your Windows build number. This can be gathered from the CMD prompt using the `cmd.exe --version` command.
```cmd.exe
C:\ cmd.exe --version
Microsoft Windows [Version 10.0.21354.1]
```
Note: The Windows Insider builds contain many updates and fixes. If you are running on the Creators Update (10.0.15063) please check to see if your issue has been resolved in a later build. If you are running on a Version below (10.0.14393), please try to update your Version.
#### Example:
`Microsoft Windows [Version 10.0.21354.1]`
### 3) Steps required to reproduce
Should include all packages and environmental variables as well as other required configuration.
#### Example: On linux
`$ sudo apt-get install traceroute && traceroute www.microsoft.com`
#### Example: On Windows
``
`$ cmd.exe`
`CD C:\Windows\System32\`
`tracert.exe`
``
### 4) Copy of the terminal output
#### Example:
```
$ traceroute www.microsoft.com
traceroute to www.microsoft.com (23.75.239.28), 30 hops max, 60 byte packets
setsockopt IP_MTU_DISCOVER: Invalid argument
```
### 5) Expected Behavior
What was the expected result of the command? Include examples / documentation if possible.
### 6) Strace of the failing command
Run the failing command under [strace](http://manpages.ubuntu.com/manpages/wily/man1/strace.1.html). Normal command structure is:
```
$ strace -ff <command>
```
> Note: `strace` can produce lengthy output. If the generated trace is more than about 20 lines please paste this into a [Gist](https://gist.github.com/) or another paste service and link in the bug.
#### Example:
```
$ strace traceroute www.microsoft.com
execve("/usr/bin/traceroute", ["traceroute", "www.microsoft.com"], [/* 22 vars */]) = 0
brk(0) = 0x7fffdd3bc000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1f4e820000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
...
...
...
```
### 7) Additional information
Some bugs require additional information such as scripts to reproduce. Please add to this section.
If there are files required, email the files to InsiderSupport@microsoft.com with:
* **Subject**: Forward to WSL Team - RE: github issue <issue #>
* **Body**: "Please forward to WSL Team" and include your attachment.
Common files are:
* Memory dumps found under C:\Windows\MEMORY.DMP
* Additional strace logs if the error occurs within a fork. The following
command generates an output file for every fork created:
```
$ strace -ff -o <outputfile> <command>
```
#### wsl --mount
If the issue is about wsl --mount, please include the output of running `wmic diskdrive get Availability,Capabilities,CapabilityDescriptions,DeviceID,InterfaceType,MediaLoaded,MediaType,Model,Name,Partitions` in an elevated command prompt.
Example:
```
C:\WINDOWS\system32>wmic diskdrive get Availability,Capabilities,CapabilityDescriptions,DeviceID,InterfaceType,MediaLoaded,MediaType,Model,Name,Partitions
Availability Capabilities CapabilityDescriptions DeviceID InterfaceType MediaLoaded MediaType Model Name Partitions
{3, 4} {"Random Access", "Supports Writing"} \\.\PHYSICALDRIVE0 SCSI TRUE Fixed hard disk media SAMSUNG MZVLB512HAJQ-000H2 \\.\PHYSICALDRIVE0 3
{3, 4} {"Random Access", "Supports Writing"} \\.\PHYSICALDRIVE1 SCSI TRUE Fixed hard disk media SAMSUNG MZVLB1T0HALR-000H2 \\.\PHYSICALDRIVE1 1
{3, 4, 10} {"Random Access", "Supports Writing", "SMART Notification"} \\.\PHYSICALDRIVE2 SCSI TRUE Fixed hard disk media ST2000DM001-1ER164 \\.\PHYSICALDRIVE2 1
```
#### Collect WSL logs for networking issues
### Collect WSL logs for networking issues
Install tcpdump in your WSL distribution using the following commands.
Note: This will not work if WSL has Internet connectivity issues.
@ -127,7 +48,7 @@ Note: This will not work if WSL has Internet connectivity issues.
# sudo apt-get -y install tcpdump
```
Install [WPR](https://learn.microsoft.com/en-us/windows-hardware/test/wpt/windows-performance-recorder)
Install [WPR](https://learn.microsoft.com/windows-hardware/test/wpt/windows-performance-recorder)
To collect WSL networking logs, do the following steps in an administrative powershell prompt:
@ -142,9 +63,10 @@ The script will output the path of the log file once done.
<!-- Preserving anchors -->
<div id="8-detailed-logs"></div>
<div id="9-networking-logs"></div>
<div id="8-collect-wsl-logs-recommended-method"></div>
### 8) Collect WSL logs (recommended method)
### Collect WSL logs (recommended method)
If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue.
@ -157,45 +79,6 @@ Set-ExecutionPolicy Bypass -Scope Process -Force
```
The script will output the path of the log file once done.
### 9) Collect WSL logs with Feedback hub
To collect WSL logs follow these steps:
#### Open Feedback Hub and enter the title and description of your issue
- Open Feedback hub and create a new issue by pressing `Windows Key + F` on your keyboard.
- Enter in the details of your issue:
- In `Summarize your feedback` copy and paste in the title of your Github Issue
- In `Explain in more detail` copy and paste a link to your Github Issue
![GIF Of networking instructions](img/networkinglog1.gif)
#### Choose the WSL category
- Select that your issue is a `Problem`
- Choose the `Developer Platform` category and the `Windows Subsystem for Linux` subcategory
![GIF Of networking instructions](img/networkinglog2.gif)
#### Recreate your problem in the 'Additional Details' section
- Select 'Other' under 'Which of the following best describes your problem'
- Click 'Recreate My Problem' under 'Attachments
- Ensure that `Include Data About:` is checked to 'Windows Subsystem for Linux'
- 'Click Start Recording' to start collecting logs
- Recreate your problem
- Click 'Stop Recording'
![GIF Of networking instructions](img/networkinglog3.gif)
#### Check your attachments and submit
- Verify your recording is attached and whether you would like to send the screenshot that is automatically attached
- Hit Submit
- Get a link to your feedback item by clicking on 'Share my Feedback' and post that link to the Github thread so we can easily get to your feedback!
![GIF Of networking instructions](img/networkinglog4.gif)
### 10) Reporting a Windows crash (BSOD)
To collect a kernel crash dump, first run the following command in an elevated command prompt:
@ -216,7 +99,7 @@ Make sure that the email body contains:
### 11) Reporting a WSL process crash
The easiest way to report a WSL process crash is by [collecting a user-mode crash dump](https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps).
The easiest way to report a WSL process crash is by [collecting a user-mode crash dump](https://learn.microsoft.com/windows/win32/wer/collecting-user-mode-dumps).
To collect dumps of all running WSL processe, please open a PowerShell prompt with admin privileges, navigate to a folder where you'd like to put your log files and run these commands:
@ -273,4 +156,4 @@ To collect time travel debugging traces:
10) Go to the folder where the trace was collected, and locate the .run file. It should look like: `wslservice*.run`
11) Share that file on the issue
11) Share that file on the issue

18
DATA_AND_PRIVACY.md Normal file
View file

@ -0,0 +1,18 @@
# WSL data & privacy
## Overview
WSL collects diagnostic data using Windows telemetry, just like other Windows components. You can disable this by opening Windows Settings, navigating to Privacy and Security -> Diagnostics & Feedback and disabling 'Diagnostic data'. You can also view all diagnostic data that you are sending in that menu using the 'View diagnostic data' option.
For more information please read the [Microsoft privacy statement](https://www.microsoft.com/privacy/privacystatement).
## What does WSL collect?
1. Usage
- Understanding what features and settings are most often used in WSL helps us make decisions on where to focus our time and energy.
2. Stability
- Monitoring bugs and system crashes assists us in prioritizing the most urgent issues.
3. Performance
- Assessing the performance of WSL gives us an understanding of what runtimes / components could be causing slow downs. This supports our commitment in providing you a speedy and effective WSL.
You can search for WSL telemetry events by looking for calls to `WSL_LOG_TELEMETRY` in the source code of this repository.

11
Directory.Build.Props Normal file
View file

@ -0,0 +1,11 @@
<Project>
<PropertyGroup>
<UseMultiToolTask>true</UseMultiToolTask>
<EnforceProcessCountAcrossBuilds>true</EnforceProcessCountAcrossBuilds>
</PropertyGroup>
<ItemDefinitionGroup>
<CustomBuild>
<BuildInParallel>true</BuildInParallel>
</CustomBuild>
</ItemDefinitionGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
Images/StoreLogo.backup.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
Images/wsl.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
Images/wslbw.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

2129
NOTICE.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,72 +1,49 @@
This repo is for:
# Welcome to the Windows Subsystem for Linux (WSL) repository
- Reporting of issues found within and when using Windows Subsystem for Linux.
Please read [CONTRIBUTING.md](https://github.com/Microsoft/WSL/blob/master/CONTRIBUTING.md) before making an issue submission
<p align="center">
<img src="./Images/Square44x44Logo.targetsize-256.png" alt="WSL logo"/>
</p>
> Do not open Github issues for Windows crashes (BSODs) or security issues. Please direct all Windows crashes and security issues to secure@microsoft.com. Issues with security vulnerabilities may be edited to hide the vulnerability details.
[Learn more about WSL](https://aka.ms/wsldocs) | [Downloads & Release notes](https://github.com/microsoft/WSL/releases) | [Contributing to WSL](./CONTRIBUTING.md)
- Surrounding discussions about the Windows Subsystem for Linux.
## About
## Reporting issues in Windows Console or WSL text rendering/user experience
Windows Subsystem for Linux (WSL) is a powerful way for you to run your Linux command-line tools, utilities and applications, all unmodified and directly on Windows without the overhead of a traditional virtual machine or dual boot setup.
Note that WSL distro's launch in the Windows Console (unless you have taken steps to launch a 3rd party console/terminal). Therefore, *please file UI/UX related issues in the [Windows Console issue tracker](https://github.com/microsoft/console)*.
You can install WSL right away by running this command inside of your Windows command line:
## Labels:
```powershell
wsl --install
```
This is your best way to interact directly with the Windows Subsystem for Linux teams. We will be monitoring and responding to issues as best we can. Please attempt to avoid filing duplicates of open or closed items when possible. Issues may be tagged with with the following labels:
You can learn more about [best practices for setup](https://learn.microsoft.com/windows/wsl/setup/environment), [overviews of WSL](https://learn.microsoft.com/windows/wsl/about) and more at our [WSL documentation page](https://learn.microsoft.com/windows/wsl/).
- **bug** The issue considered to be a bug internally by the dev team. This tag is generally for gaps in implemented (read: intended to be working) WSL behavior. Things marked with **bug** have a corresponding bug in on Microsofts internal bug tracking system. Example: "du -h reports wrong file size on DrvFs" [(#1894)](https://github.com/microsoft/WSL/issues/1894)
## Related repositories
- **feature** Denotes something understood as not working and is not yet implemented. Example: "Cuda can not be installed" [(#327)](https://github.com/microsoft/WSL/issues/327)
WSL also has related open source repositories:
- **fixinbound** / **fixedinNNNN** The bug or feature request originally submitted has been addressed in whole or in part. Related or ongoing bug or feature gaps should be opened as a new issue submission if one does not already exist.
- [microsoft/WSL2-Linux-Kernel](https://github.com/microsoft/WSL2-Linux-Kernel) - The Linux kernel shipped with WSL
- [microsoft/WSLg](https://github.com/microsoft/wslg) - Support for Linux GUI apps in WSL
- [microsoftdocs/wsl](https://github.com/microsoftdocs/wsl) - WSL documentation at aka.ms/wsldocs
- **duplicate** The submission is substantially duplicative of an existing issue, and/or has the same underlying cause.
## Contributing
- **need-repro** The issue submission is missing fields from the issue [template](https://github.com/microsoft/WSL/tree/master/.github/ISSUE_TEMPLATE), cannot be reproduced with the information provided, or is not actionable.
This project welcomes contributions of all types, including coding features / bug fixes, documentation fixes, design proposals and more.
- **discussion** / **question** Submissions which are not a bug report or feature request. Example: Windows Subsystem for Linux is not open source [(#178)](https://github.com/Microsoft/WSL/issues/178)
We ask that before you start working on a contribution, please read our [Contributor's Guide](./CONTRIBUTING.md).
- **bydesign** / **linux-behavior** Denotes that an issue that is considered working as intended or would behave analogously on a native Linux kernel.
For guidance on developing for WSL, please read the [developer docs](./doc/docs/dev-loop.md) for instructions on how to build WSL from source and details on its architecture.
- **console** The submission should be directed to the [console issue tracker](https://github.com/microsoft/console/issues).
## Code of Conduct
- **documentation** The submission should be directed to the [WSL documentation issue tracker](https://github.com/MicrosoftDocs/WSL).
This project has adopted the [Microsoft Open Source Code of Conduct](./CODE_OF_CONDUCT.md)
- **wsl2** - The issue relates specifically to WSL 2.
## Trademarks
- **fixed-in-wsl2** - The issue could be resolved by switching the distro to use the WSL 2 architecture.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsofts Trademark & Brand Guidelines](https://www.microsoft.com/legal/intellectualproperty/trademarks). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-partys policies.
Additional tags may be used to denote specific types of issues.
## Privacy and telemetry
- **9p-linux-file-access** - The issue is related to accessing Linux files from Windows.
The application logs basic diagnostic data (telemetry). For more information on privacy and what we collect, see our [data and privacy documentation](DATA_AND_PRIVACY.md).
## Closing:
Issues may be closed by the original poster at any time. We will close issues if:
- The issue is not a bug or feature request
- The issue has been addressed
- The issue is a duplicate of another issue
- Discussions or questions that have ran their course
### Microsoft Links:
- [Microsoft Docs](https://docs.microsoft.com/en-us/windows/wsl/about)
- [Release Notes](https://docs.microsoft.com/en-us/windows/wsl/release-notes)
- [WSL Blog](https://blogs.msdn.microsoft.com/wsl) (Historical)
- [Command Line Blog](https://blogs.msdn.microsoft.com/commandline/) (Active)
### Community Links:
- Stack Overflow: https://stackoverflow.com/questions/tagged/wsl
- Ask Ubuntu: https://askubuntu.com/questions/tagged/wsl
- reddit: https://www.reddit.com/r/bashonubuntuonwindows
- List of programs that work and don't work
- https://github.com/ethanhs/WSL-Programs
- https://github.com/davatron5000/can-i-subsystem-it
- Awesome WSL: https://github.com/sirredbeard/Awesome-WSL
- Tips and guides for new bash users: https://github.com/abergs/ubuntuonwindows
### Troubleshooting:
Common troubleshooting issues and solutions are available on our [MSDN documentation](https://msdn.microsoft.com/en-us/commandline/wsl/troubleshooting).
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsofts privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.

View file

@ -38,4 +38,4 @@ We prefer all communications to be in English.
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
<!-- END MICROSOFT SECURITY.MD BLOCK -->
<!-- END MICROSOFT SECURITY.MD BLOCK -->

17
SUPPORT.md Normal file
View file

@ -0,0 +1,17 @@
# Support
## How to file issues and get help
This project uses [GitHub Issues][gh-issue] to [track bugs][gh-bug] and [feature requests][gh-feature]. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or
feature request as a new Issue.
For general information on the Windows Subsystem for Linux, including help, tutorials, how-tos and reference guides, please view our [WSL documentation](https://docs.microsoft.com/windows/wsl/).
## Microsoft Support Policy
Technical Support for the use of WSL may also be available from Microsofts Customer Support Services (CSS). If you are a Premier or Unified Support customer, you may reach out to your account manager for further assistance. Otherwise, you may visit Microsofts [Support For Business site](https://support.serviceshub.microsoft.com/supportforbusiness/create) to [open a new support case for WSL](https://support.serviceshub.microsoft.com/supportforbusiness/create?sapid=9d5af292-506b-63ca-cb2c-7f4eaa380c56).
[gh-issue]: https://github.com/microsoft/WSL/issues/new/choose
[gh-bug]: https://github.com/microsoft/WSL/issues/new?assignees=&labels=&template=bug_report.md&title=
[gh-feature]: https://github.com/microsoft/WSL/issues/new?assignees=&labels=feature&template=feature_request.md&title=

36
UserConfig.cmake.sample Normal file
View file

@ -0,0 +1,36 @@
# Sample user configuration
message(STATUS "Loading user configuration")
# # Uncomment to enable development packages (smaller, faster to install)
# # Note: system.vhd fails to mount if symlink / hardlink, so COPY is needed.
# set(WSL_DEV_BINARY_PATH "C:/wsldev")
# file(MAKE_DIRECTORY ${WSL_DEV_BINARY_PATH})
# file(CREATE_LINK "${KERNEL_SOURCE_DIR}/bin/${TARGET_PLATFORM}/kernel" "${WSL_DEV_BINARY_PATH}/kernel" SYMBOLIC)
# file(COPY_FILE "${WSLG_SOURCE_DIR}/${TARGET_PLATFORM}/system.vhd" "${WSL_DEV_BINARY_PATH}/system.vhd" ONLY_IF_DIFFERENT)
# file(COPY_FILE "${KERNEL_SOURCE_DIR}/bin/${TARGET_PLATFORM}/modules.vhd" "${WSL_DEV_BINARY_PATH}/modules.vhd" ONLY_IF_DIFFERENT)
# file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/msrdc.exe" "${WSL_DEV_BINARY_PATH}/msrdc.exe" SYMBOLIC)
# file(CREATE_LINK "${WSLG_SOURCE_DIR}/wslg.rdp" "${WSL_DEV_BINARY_PATH}/wslg.rdp" SYMBOLIC)
# file(CREATE_LINK "${WSLG_SOURCE_DIR}/wslg_desktop.rdp" "${WSL_DEV_BINARY_PATH}/wslg_desktop.rdp" SYMBOLIC)
# file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/rdclientax.dll" "${WSL_DEV_BINARY_PATH}/rdclientax.dll" SYMBOLIC)
# file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/rdpnanoTransport.dll" "${WSL_DEV_BINARY_PATH}/rdpnanoTransport.dll" SYMBOLIC)
# file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/RdpWinStlHelper.dll" "${WSL_DEV_BINARY_PATH}/RdpWinStlHelper.dll" SYMBOLIC)
# file(CREATE_LINK "${MSAL_SOURCE_DIR}/${TARGET_PLATFORM}/msal.wsl.proxy.exe" "${WSL_DEV_BINARY_PATH}/msal.wsl.proxy.exe" SYMBOLIC)
# file(CREATE_LINK "${BIN}/wsldevicehost.dll" "${WSL_DEV_BINARY_PATH}/wsldevicehost.exe" SYMBOLIC)
# file(CREATE_LINK "${DIRECT3D_SOURCE_DIR}/lib/${TARGET_PLATFORM}" "${WSL_DEV_BINARY_PATH}/lib" SYMBOLIC)
# foreach(LANG ${SUPPORTED_LANGS})
# file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/${LANG}" "${WSL_DEV_BINARY_PATH}/${LANG}" SYMBOLIC)
# endforeach()
# # Uncomment to skip building, packaging and installing wslsettings
# set(WSL_BUILD_WSL_SETTINGS false)
# # Uncomment to generate a "thin" MSI package which builds and installs faster
# set(WSL_BUILD_THIN_PACKAGE true)
# # Uncomment to install the package as part of the build
# set(WSL_POST_BUILD_COMMAND "powershell;./tools/deploy/deploy-to-host.ps1")
# # Uncomment to reduce the verbosity of the appx package build
# set(WSL_SILENT_APPX_BUILD true)

35
cgmanifest.json Normal file
View file

@ -0,0 +1,35 @@
{
"version": 1,
"$schema": "https://json.schemastore.org/component-detection-manifest.json",
"registrations": [
{
"component": {
"type": "git",
"git": {
"repositoryUrl": "https://github.com/microsoft/GSL",
"commitHash": "0f6dbc9e2915ef5c16830f3fa3565738de2a9230"
}
}
},
{
"component": {
"type": "git",
"git": {
"repositoryUrl": "https://github.com/llvm/llvm-project",
"commitHash": "d32170dbd5b0d54436537b6b75beaf44324e0c28"
}
}
},
{
"component": {
"type": "other",
"other": {
"name": "libarchive",
"version": "3.7.7",
"downloadUrl": "https://github.com/libarchive/libarchive/releases/download/v3.7.7/libarchive-3.7.7.tar.gz",
"hash": "sha1:918692098b11db61aff23684ab04f375e4a68f69"
}
}
}
]
}

39
cloudtest/CMakeLists.txt Normal file
View file

@ -0,0 +1,39 @@
set(OUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cloudtest)
file(MAKE_DIRECTORY ${OUT})
if (${TARGET_PLATFORM} STREQUAL x64)
set(CLOUDTEST_IMAGES
"wsl-test-image-rs_prerelease-2025-01-30"
"wsl-test-image-win11-23h2-ent-2024-11-18"
"wsl-test-image-2022-datacenter-g2-2024-09-10"
"wsl-test-image-win10-22h2-ent-g2-2024-09-10")
set(CLOUDTEST_TEST_PACKAGES "Test_Packages_2024_02_27")
set(DUMPTOOL_DROP "DumpTool_X64_2025-01-27")
elseif (${TARGET_PLATFORM} STREQUAL arm64)
set(CLOUDTEST_IMAGES)
else()
message(FATAL_ERROR "Unsupported target platform: ${TARGET_PLATFORM}")
endif()
# Passed down to test-setup.ps1 to determine if -AllowUnsigned should be passed to Add-AppxPackage
if (OFFICIAL_BUILD)
set(ALLOW_UNSIGNED_PACKAGE "0")
else()
set(ALLOW_UNSIGNED_PACKAGE "1")
endif()
function(add_test_group image version)
set(DIR ${OUT}/${image}-wsl${version})
file(MAKE_DIRECTORY ${DIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/TestMap.xml.in ${DIR}/TestMap.xml)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/TestGroup.xml.in ${DIR}/TestGroup.xml)
endfunction()
foreach(image ${CLOUDTEST_IMAGES})
add_test_group("${image}" "1")
add_test_group("${image}" "2")
endforeach()

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<TestJobGroup EnableProcessJobObjectBreakaway="true">
<ResourceSpec>
<Resource SKU="Standard_D4_v3" Image="${image}"/>
</ResourceSpec>
<Setup TimeoutMins="30">
<BuildFiles>
<Copy Src="[drop]\bundle\Microsoft.WSL_${PACKAGE_VERSION}_x64_ARM64.msixbundle" Dest="[WorkingDirectory]" IsRecursive="false"/>
<Copy Src="[drop]\testbin\${TARGET_PLATFORM}\release\*" Dest="[WorkingDirectory]\" IsRecursive="true" Writable="true"/>
<Copy Src="[drop]\testbin\${TARGET_PLATFORM}\test_distro.tar.xz" Dest="[WorkingDirectory]" IsRecursive="false" Writable="true"/>
<Copy Src="[drop]\testbin\test-setup.ps1" Dest="[WorkingDirectory]\" IsRecursive="false" />
<Copy Src="[drop]\testbin\CloudTest-Setup.bat" Dest="[WorkingDirectory]\" IsRecursive="false" />
<Copy Src="[drop]\testbin\wsl.wprp" Dest="[WorkingDirectory]\" IsRecursive="false" />
<Copy Src="[drop]\testbin\unit_tests\*" Dest="[WorkingDirectory]\unit_tests" IsRecursive="true" Writable="true"/>
<Copy Src="[test_packages]\*" Dest="[WorkingDirectory]" IsRecursive="false" />
<Copy Src="[dump_tool]\DumpTool.exe" Dest="[WorkingDirectory]" IsRecursive="false" />
</BuildFiles>
<Scripts>
<Script Path="[WorkingDirectory]\CloudTest-Setup.bat" Args="[WorkingDirectory] [LoggingDirectory]" />
</Scripts>
</Setup>
<TestJob Name="CloudTest.Taef" TimeoutMins="240">
<Execution Type="TAEF" Path="[WorkingDirectory]\wsltests.dll" Args="/p:bugReportDirectory=[LoggingDirectory]\BugReportOutput /errorOnCrash /testmode:etwlogger /EtwLogger:WPRProfileFile=[WorkingDirectory]\wsl.wprp /EtwLogger:WPRProfile=WSL /EtwLogger:SavePoint=ExecutionComplete /EtwLogger:RecordingScope=Execution /p:SetupScript=.\test-setup.ps1 /p:Package=[WorkingDirectory]\Microsoft.WSL_${PACKAGE_VERSION}_x64_ARM64.msixbundle /p:Version=${version} /p:AllowUnsigned=${ALLOW_UNSIGNED_PACKAGE} /p:UnitTestsPath=[WorkingDirectory]\unit_tests /p:DistroPath=[WorkingDirectory]\test_distro.tar.xz /p:DistroName=test_distro /logOutput:High /p:RedirectStdout=[LoggingDirectory]\stdout.txt /p:RedirectStderr=[LoggingDirectory]\stderr.txt /p:KernelLogs=[LoggingDirectory]\dmesg.txt /p:DumpFolder=[LoggingDirectory] /p:WerReport /p:LogDmesg /p:PipelineBuildId=${PIPELINE_BUILD_ID} /p:DumpTool=DumpTool.exe" />
</TestJob>
</TestJobGroup>

34
cloudtest/TestMap.xml.in Normal file
View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<TestMap>
<TestJobGroup Name="TaefTestsGroup" TestSystem="Default" ConfigPath="[BuildRoot]\testbin\${TARGET_PLATFORM}\cloudtest\${image}-wsl${version}\TestGroup.xml" IsActive="true"/>
<Providers>
<Provider Type="PipelineArtifacts">
<Properties>
<Add Name="CloudTest.ProviderCustomName" Value="[drop]" />
<Add Name="PipelineArtifactBuildUrl" Value="https://microsoft.visualstudio.com/Microsoft.WSL/_build/results?buildId=${PIPELINE_BUILD_ID}"/>
<Add Name="PipelineArtifactName" Value="drop_wsl_build"/>
</Properties>
</Provider>
<Provider Type="VSODrop">
<Properties>
<Add Name="CloudTest.ProviderCustomName" Value="[test_distro]" />
<!-- When updating the drops for this make sure the rentention is set to never expire -->
<Add Name="DropURL" Value="https://microsoft.artifacts.visualstudio.com/DefaultCollection/_apis/drop/drops/WSL/${CLOUDTEST_TEST_DISTRO_DROP}"/>
</Properties>
</Provider>
<Provider Type="VSODrop">
<Properties>
<Add Name="CloudTest.ProviderCustomName" Value="[test_packages]" />
<!-- When updating the drops for this make sure the rentention is set to never expire -->
<Add Name="DropURL" Value="https://microsoft.artifacts.visualstudio.com/DefaultCollection/_apis/drop/drops/WSL/${CLOUDTEST_TEST_PACKAGES}"/>
</Properties>
</Provider>
<Provider Type="VSODrop">
<Properties>
<Add Name="CloudTest.ProviderCustomName" Value="[dump_tool]" />
<!-- When updating the drops for this make sure the rentention is set to never expire -->
<Add Name="DropURL" Value="https://microsoft.artifacts.visualstudio.com/DefaultCollection/_apis/drop/drops/WSL/${DUMPTOOL_DROP}"/>
</Properties>
</Provider>
</Providers>
</TestMap>

67
cmake/FindIDL.cmake Normal file
View file

@ -0,0 +1,67 @@
function(add_idl target idl_files_with_proxy idl_files_no_proxy)
set(OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PLATFORM}/${CMAKE_BUILD_TYPE})
file(MAKE_DIRECTORY ${OUTPUT_DIR})
set(TARGET_OUTPUTS)
set(IDL_DEFINITIONS "")
get_directory_property(IDL_DEFS COMPILE_DEFINITIONS )
foreach(e ${IDL_DEFS})
set(IDL_DEFINITIONS ${IDL_DEFINITIONS} /D${e})
endforeach()
string(TOLOWER ${TARGET_PLATFORM} IDL_ENV)
foreach(idl_file ${idl_files_with_proxy})
cmake_path(GET idl_file STEM IDL_NAME)
set(IDL_HEADER ${OUTPUT_DIR}/${IDL_NAME}.h)
# Adding a _${TARGET_PLATFORM} to work around object files having
# the same paths regardless of TARGET_PLATFORM, which can cause the linker to fail with:
# "fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'ARM64'"
set(IDL_I ${OUTPUT_DIR}/${IDL_NAME}_i_${TARGET_PLATFORM}.c)
set(IDL_P ${OUTPUT_DIR}/${IDL_NAME}_p_${TARGET_PLATFORM}.c)
set(IDL_DLLDATA ${OUTPUT_DIR}/dlldata_${TARGET_PLATFORM}.c)
set(MIDL_OUTPUT ${IDL_HEADER} ${IDL_I} ${IDL_C} ${IDL_DLLDATA})
add_custom_command(
OUTPUT ${MIDL_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/${target}
COMMAND midl /nologo /target NT100 /env "${IDL_ENV}" /Zp8 /char unsigned /ms_ext /c_ext /h ${IDL_HEADER} /iid ${IDL_I} /proxy ${IDL_P} /dlldata ${IDL_DLLDATA} ${idl_file} ${IDL_DEFINITIONS}
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/${target}"
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS ${idl_file}
MAIN_DEPENDENCY ${idl_file}
VERBATIM
)
set_source_files_properties(${MIDL_OUTPUT} PROPERTIES GENERATED TRUE)
list(APPEND TARGET_OUTPUTS ${MIDL_OUTPUT})
endforeach()
foreach(idl_file ${idl_files_no_proxy})
cmake_path(GET idl_file STEM IDL_NAME)
set(IDL_HEADER ${OUTPUT_DIR}/${IDL_NAME}.h)
add_custom_command(
OUTPUT ${IDL_HEADER} ${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/${target}
COMMAND midl /nologo /target NT100 /env "${IDL_ENV}" /Zp8 /char unsigned /ms_ext /c_ext /h ${IDL_HEADER} ${idl_file} ${IDL_DEFINITIONS}
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/${target}"
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS ${idl_file}
MAIN_DEPENDENCY ${idl_file}
VERBATIM
)
set_source_files_properties(${IDL_HEADER} PROPERTIES GENERATED TRUE)
list(APPEND TARGET_OUTPUTS ${IDL_HEADER})
endforeach()
add_custom_target(${target} DEPENDS ${TARGET_OUTPUTS} SOURCES ${idl_files_with_proxy} ${idl_files_no_proxy})
endfunction()

104
cmake/FindLINUXBUILD.cmake Normal file
View file

@ -0,0 +1,104 @@
function(build_linux_objects sources headers)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PLATFORM}/${CMAKE_BUILD_TYPE})
foreach(e ${sources})
cmake_path(GET e FILENAME object_name)
set(object "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PLATFORM}/${CMAKE_BUILD_TYPE}/${object_name}.o")
set(objects ${objects} ${object})
if("${e}" MATCHES "^.*\.c$")
set(compiler ${LINUX_CC})
set(flags ${LINUX_CFLAGS})
else()
set(compiler ${LINUX_CXX})
set(flags ${LINUX_CXXFLAGS})
endif()
add_custom_command(
OUTPUT ${object}
COMMAND ${compiler} ${flags} ${LINUX_BUILD_TYPE_FLAGS} ${e} -c -o ${object}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
MAIN_DEPENDENCY ${e}
DEPENDS ${headers} # Every object depends on all headers to trigger a rebuild if a header is changed
VERBATIM
)
endforeach()
set(objects ${objects} PARENT_SCOPE)
endfunction()
function(add_linux_library_impl target sources headers add_sources)
set(ar_output "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${target}.a")
build_linux_objects("${sources}" "${headers}")
add_custom_command(
OUTPUT ${ar_output} ${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/${target}
COMMAND ${LINUX_AR} crus ${ar_output} ${objects}
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/${target}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${objects}
VERBATIM
)
if (${add_sources})
add_custom_target(${target} DEPENDS ${ar_output} SOURCES ${sources} ${headers})
else()
add_custom_target(${target} DEPENDS ${ar_output})
endif()
set_source_files_properties(${ar_output} PROPERTIES GENERATED TRUE)
endfunction()
function(add_linux_library target sources headers)
add_linux_library_impl(${target} "${sources}" "${headers}" TRUE)
endfunction()
function(add_linux_library_no_sources target sources headers)
add_linux_library_impl(${target} "${sources}" "${headers}" FALSE)
endfunction()
function(add_linux_executable target sources headers librairies)
set(output "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${target}")
set(output_unstripped "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${target}.unstripped")
build_linux_objects("${sources}" "${headers}")
set(libs -lunwind -lc++abi -lc++)
foreach(e ${librairies})
set(libs ${libs} -l${e})
# Note: This makes the assumption that all librairies are static (.a and not .so).
# Executables need to depend on both the target and the underlying library file, so that
# the libraries target get analyzed for changes, and the executable gets linked again if the .a files changed.
list(APPEND lib_targets "lib${e}")
list(APPEND lib_files "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/lib${e}.a")
endforeach()
if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(stripped_output "${output}")
set(output "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${target}.debug")
add_custom_command(
OUTPUT ${stripped_output}
COMMAND ${LLVM_INSTALL_DIR}/llvm-strip.exe "${output}" -o "${stripped_output}"
COMMAND ${LLVM_INSTALL_DIR}/llvm-objcopy.exe --add-gnu-debuglink "${output}" "${stripped_output}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${output}
VERBATIM
)
endif()
add_custom_command(
OUTPUT ${output}
COMMAND ${LINUX_CXX} -o ${output} ${LINUXSDK_PATH}/lib/crti.o ${LINUXSDK_PATH}/lib/crt1.o ${objects} ${LINUXSDK_PATH}/lib/crtn.o ${LINUX_LDFLAGS} ${libs}
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/${target}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${objects} ${lib_files}
VERBATIM
)
add_custom_target(${target} DEPENDS ${output} ${stripped_output} SOURCES ${sources} ${headers})
add_dependencies(${target} ${lib_targets})
endfunction()

23
cmake/FindMC.cmake Normal file
View file

@ -0,0 +1,23 @@
function(add_mc target mc_file)
cmake_path(GET mc_file STEM MC_NAME)
set(OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}\\${TARGET_PLATFORM}\\${CMAKE_BUILD_TYPE})
set(RC_FILE ${OUTPUT_DIR}/${MC_NAME}.rc)
set(HEADER_FILE ${OUTPUT_DIR}/${MC_NAME}.h)
add_custom_command(
OUTPUT ${RC_FILE} ${HEADER_FILE} ${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/${target}
COMMAND mc.exe -A -b -c -h ${OUTPUT_DIR} -r ${OUTPUT_DIR} ${mc_file}
COMMAND rc.exe -nologo -fo${OUTPUT_DIR}\\${MC_NAME}.res ${RC_FILE}
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/${target}"
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS ${mc_file}
MAIN_DEPENDENCY ${mc_file}
VERBATIM
)
add_custom_target(${target} DEPENDS ${RC_FILE} SOURCES ${mc_file})
set_source_files_properties(${RC_FILE} PROPERTIES GENERATED TRUE)
endfunction()

84
cmake/findAppx.cmake Normal file
View file

@ -0,0 +1,84 @@
function(add_appx_target target binaries manifest_in output_package dependencies)
set(PACKAGE_LAYOUT "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PLATFORM}/package_layout")
set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/AppxManifest.xml")
set(PRI_CONF "${CMAKE_CURRENT_BINARY_DIR}/priconf.xml")
set(OUTPUT_RESOURCES_PRI "${CMAKE_CURRENT_BINARY_DIR}/resources.pri")
# generate the list of languages for the appxmanifest
set(SUPPORTED_LANGS_MANIFEST_ENTRIES "")
foreach(LANG ${SUPPORTED_LANGS})
string(TOUPPER "${LANG}" LANG)
set(SUPPORTED_LANGS_MANIFEST_ENTRIES "${SUPPORTED_LANGS_MANIFEST_ENTRIES}\n <Resource Language=\"${LANG}\"/>")
endforeach()
configure_file(${manifest_in} ${MANIFEST})
file(MAKE_DIRECTORY ${PACKAGE_LAYOUT})
# images
file(MAKE_DIRECTORY ${PACKAGE_LAYOUT}/Images)
set(RESOURCES_DEPENDENCY)
file(GLOB IMAGES RELATIVE ${PROJECT_SOURCE_DIR}/ "${PROJECT_SOURCE_DIR}/images/*.png")
foreach(e ${IMAGES})
file(CREATE_LINK ${PROJECT_SOURCE_DIR}/${e} ${PACKAGE_LAYOUT}/${e} SYMBOLIC)
list(APPEND RESOURCES_DEPENDENCY ${PROJECT_SOURCE_DIR}/${e})
endforeach()
# Localization. Note: these files aren't added to the resource map, so they aren't added to the package,
# but they are used by makepri to generate resources.pri
file(CREATE_LINK ${PROJECT_SOURCE_DIR}/localization/strings ${PACKAGE_LAYOUT}/Strings SYMBOLIC)
foreach(binary ${binaries})
set(BINARY_SRC "${BIN}/${binary}")
set(BINARY_DEST "${PACKAGE_LAYOUT}/${binary}")
add_custom_command(
OUTPUT ${BINARY_DEST}
COMMAND ${CMAKE_COMMAND} -E create_symlink "${BINARY_SRC}" "${BINARY_DEST}"
DEPENDS ${BINARY_SRC}
)
list(APPEND BINARIES_DEPENDENCY ${BINARY_DEST})
endforeach()
# Reduce the output of makeappx unless WSL_APPX_DEBUG is set to make the build output nicer to read
if (WSL_SILENT_APPX_BUILD)
set(COMMAND_SUFFIX "2>NUL;>;NUL")
endif ()
# generate priconf.xml
string(REPLACE ";" "_" SUPPORTED_LANGS_STR "${SUPPORTED_LANGS}")
add_custom_command(
OUTPUT ${PRI_CONF}
COMMAND makepri.exe createconfig /cf ${PRI_CONF} /dq ${SUPPORTED_LANGS_STR} /pv 10.0 /o ${COMMAND_SUFFIX}
COMMAND_EXPAND_LISTS
)
# generate resources.pri
add_custom_command(
OUTPUT ${OUTPUT_RESOURCES_PRI} ${CMAKE_CURRENT_BINARY_DIR}/resources.map.txt
COMMAND makepri.exe new /pr ${PACKAGE_LAYOUT} /cf ${PRI_CONF} /of ${OUTPUT_RESOURCES_PRI} /mn ${MANIFEST} /mf AppX /o /IndexOptions +lf ${COMMAND_SUFFIX}
COMMAND_EXPAND_LISTS
DEPENDS ${PRI_CONF} ${MANIFEST} ${BINARIES_DEPENDENCY} ${RESOURCES_DEPENDENCY} # Make sure the package is rebuilt if any of the resources change
)
# make appx
add_custom_command(
OUTPUT ${output_package}
COMMAND makeappx.exe pack /m ${MANIFEST} /f ${CMAKE_CURRENT_BINARY_DIR}/resources.map.txt /p ${output_package} /o ${COMMAND_SUFFIX}
COMMAND ${PACKAGE_SIGN_COMMAND} ${output_package} ${COMMAND_SUFFIX}
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/${target}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND_EXPAND_LISTS
DEPENDS ${MANIFEST} ${BINARIES_DEPENDENCY} ${OUTPUT_RESOURCES_PRI} ${CMAKE_CURRENT_BINARY_DIR}/resources.map.txt # Make sure the package is rebuilt if any of the binaries or resources change
)
add_custom_target(${target} DEPENDS ${output_package})
foreach(e ${dependencies})
add_dependencies(${target} ${e})
endforeach()
set_target_properties(${target} PROPERTIES EXCLUDE_FROM_ALL FALSE SOURCES ${manifest_in})
set_source_files_properties(${output_package} PROPERTIES GENERATED TRUE)
endfunction()

42
cmake/findNuget.cmake Normal file
View file

@ -0,0 +1,42 @@
function(find_nuget_package name var_name path)
string(JSON "${var_name}_VERSION" GET ${NUGET_PACKAGES_JSON} "${name}")
set(${var_name}_SOURCE_DIR "${CMAKE_BINARY_DIR}/packages/${name}.${${var_name}_VERSION}${path}" PARENT_SCOPE)
set(${var_name}_VERSION "${${var_name}_VERSION}" PARENT_SCOPE)
endfunction()
function (restore_nuget_packages)
# Fetch nuget.exe
FILE(DOWNLOAD
https://dist.nuget.org/win-x86-commandline/v5.10.0/nuget.exe
${CMAKE_BINARY_DIR}/_deps/nuget.exe
EXPECTED_HASH SHA256=852b71cc8c8c2d40d09ea49d321ff56fd2397b9d6ea9f96e532530307bbbafd3)
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS
${CMAKE_CURRENT_LIST_DIR}/packages.config
${CMAKE_CURRENT_LIST_DIR}/nuget.config)
# Restore nuget packages
execute_process(COMMAND
${CMAKE_BINARY_DIR}/_deps/nuget.exe restore packages.config -SolutionDirectory ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMAND_ERROR_IS_FATAL ANY)
endfunction()
function (parse_nuget_packages_versions)
# Parse the list of available packages
set(CMD "$packages=@{}; (Select-Xml -path ${CMAKE_SOURCE_DIR}/packages.config /packages).Node.ChildNodes | Where-Object { $_.name -ne '#whitespace'} | % {$packages.add($_.id, $_.Attributes['version'].Value) }; $packages | ConvertTo-Json | Write-Host")
execute_process(
COMMAND powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -Command "${CMD}"
OUTPUT_VARIABLE output
COMMAND_ERROR_IS_FATAL ANY)
set(NUGET_PACKAGES_JSON ${output} PARENT_SCOPE)
endfunction()

26
cmake/findVersion.cmake Normal file
View file

@ -0,0 +1,26 @@
function(get_version_impl command var_name)
execute_process(
COMMAND powershell.exe
-NoProfile
-NonInteractive
-ExecutionPolicy Bypass
-Command "$env:Path += ';${GITVERSION_SOURCE_DIR}' ; . .\\tools\\devops\\version_functions.ps1 ; ${command}"
OUTPUT_VARIABLE OUTPUT_VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND_ERROR_IS_FATAL ANY)
string(STRIP "${OUTPUT_VERSION}" OUTPUT_VERSION)
SET(${var_name} ${OUTPUT_VERSION} PARENT_SCOPE)
endfunction()
function(find_commit_hash var_name)
get_version_impl("Get-Current-Commit-Hash" "command_output")
SET(${var_name} ${command_output} PARENT_SCOPE)
endfunction()
function(find_version msix_var_name nuget_var_name)
get_version_impl("Get-VersionInfo -Nightly $false | ConvertTo-Json" "command_output")
string(JSON "${msix_var_name}" GET "${command_output}" MsixVersion)
string(JSON "${nuget_var_name}" GET "${command_output}" NugetVersion)
return(PROPAGATE ${msix_var_name} ${nuget_var_name})
endfunction()

10
doc/README.md Normal file
View file

@ -0,0 +1,10 @@
# WSL open source documentation
Build instructions:
```
$ pip install mkdocs mkdocs-mermaid2-plugin
$ mkdocs serve
```
You can then view the documentation at `http://127.0.0.1:8000/`.

66
doc/docs/debugging.md Normal file
View file

@ -0,0 +1,66 @@
# Debugging WSL
## Logging
There are multiple sources of logging in WSL. The main one is the ETL trace that is emitted from Windows processes.
To collect an ETL trace, run ([link to wsl.wprp](https://github.com/microsoft/WSL/blob/master/diagnostics/wsl.wprp)):
```
wpr -start wsl.wprp -filemode
[reproduce the issue]
wpr -stop logs.ETL
```
Once the log file is saved, you can use [WPA](https://apps.microsoft.com/detail/9n58qrw40dfw?hl=en-US&gl=US) to view the logs.
Notable ETL providers:
- `Microsoft.Windows.Lxss.Manager`: Logs emitted from wslservice.exe
Important events:
- `GuestLog`: Logs from the vm's dmesg
- `Error`: Unexpected errors
- `CreateVmBegin`, `CreateVmEnd`: Virtual machine lifetime
- `CreateNetworkBegin`, `CreateNetworkEnd`: Networking configuration
- `SentMessage`, `ReceivedMessaged`: Communication on the hvsocket channels with Linux.
- `Microsoft.Windows.Subsystem.Lxss`: Other WSL executables (wsl.exe, wslg.exe, wslconfig.exe, wslrelay.exe, ...)
Important events:
- `UserVisibleError`: An error was displayed to the user
- `Microsoft.Windows.Plan9.Server`: Logs from the Windows plan9 server (used when accessing /mnt/ shares and running Windows)
On the Linux side, the easiest way to access logs is to look at `dmesg` or use the debug console, which can enabled by writing:
```
[wsl2]
debugConsole=true
```
to `%USERPROFILE%/.wslconfig` and restarting WSL
## Attaching debuggers
Usermode can be attached to WSL Windows processes (wsl.exe, wslservice.exe, wslrelay.exe, ...). The symbols are available under the `bin/<platform>/<target>` folder.
You can also use [this trick](https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#11-reporting-a-wsl-process-crash) to automatically collect crash dumps when processes crash.
## Linux debugging
`gdb` can be attached to Linux processes (see [man gdb](https://man7.org/linux/man-pages/man1/gdb.1.html)).
The simplest way to debug a WSL process with gdb is to use the `/mnt` mountpoints to access the code from gdb.
Once started, just use `dir /path/to/wsl/source` in gdb to connect the source files.
## Root namespace debugging
Some WSL process such as `gns` or `mini_init` aren't accessible from within WSL distributions. To attach a debugger to those, use the debug shell via:
```
wsl --debug-shell
```
You can then install `gdb` by running `tdnf install gdb` and start debugging processes.

72
doc/docs/dev-loop.md Normal file
View file

@ -0,0 +1,72 @@
# Building WSL
## Prerequisites
The following tools are required to build WSL:
- CMake >= 2.25
- Can be installed with `winget install Kitware.CMake`
- Visual Studio with the following components:
- Windows SDK 26100
- MSBuild
- Universal Windows platform support for v143 build tools (X64 and ARM64)
- MSVC v143 - VS 2020 C++ ARM64 build tools (Latest + Spectre) (X64 and ARM64)
- C++ core features
- C++ ATL for latest v143 tools (X64 and ARM64)
- C++ Clang compiler for Windows
- .NET desktop development
- .NET WinUI app development tools
## Building WSL
Once you have cloned the repository, generate the Visual Studio solution by running:
```
cmake .
```
This will generate a `wsl.sln` file that you can build either with Visual Studio, or via `cmake --build .`.
Build parameters:
- `cmake . -A arm64`: Build a package for ARM64
- `cmake . -DCMAKE_BUILD_TYPE=Release`: Build for release
- `cmake . -DBUILD_BUNDLE=TRUE`: Build a bundle msix package (requires building ARM64 first)
Note: To build and deploy faster during development, see options in `UserConfig.cmake`.
## Deploying WSL
Once the build is complete, you can install WSL by installing the MSI package found under `bin\<platform>\<target>\wsl.msi`, or by running `powershell tools\deploy\deploy-to-host.ps1`.
To deploy on a Hyper-V virtual machine, you can use `powershell tools\deploy\deploy-to-vm.ps1 -VmName <vm> -Username <username> -Password <password>`
## Running tests
To run unit tests, run: `bin\<platform>\<target>\test.bat`. There's quite a lot of tests so you probably don't want to run everything. Here's a reasonable subset:
`bin\<platform>\<target>\test.bat /name:*UnitTest*`
To run a specific test case run:
`bin\<platform>\<target>\test.bat /name:<class>::<test>`
Example: `bin\x64\debug\test.bat /name:UnitTests::UnitTests::ModernInstall`
To run the tests for WSL1, add `-Version 1`.
Example: `bin\x64\debug\test.bat -Version 1`
After running the tests once, you can add `-f` to skip the package installation, which makes the tests faster (this requires test_distro to be the default WSL distribution).
Example:
```
wsl --set-default test_distro
bin\x64\debug\test.bat /name:*UnitTest* -f
```
## Debugging tests
See [debugging](debugging.md) for general debugging instructions.
To attach a debugging to the unit test process, use: `/waitfordebugger` when calling `test.bat`.
Use `/breakonfailure` to automatically break on the first test failure.

10
doc/docs/index.md Normal file
View file

@ -0,0 +1,10 @@
# WSL technical documentation
This site contains the developer documentation for the Windows Subsystem for Linux.
For user documentation, including installation and configuration, see [https://learn.microsoft.com/windows/wsl/](https://learn.microsoft.com/windows/wsl/).
To get started developing (building, testing and deploying), see [Getting started](dev-loop.md).
To learn more about how WSL works, see [technical documentation](technical-documentation/index.md)

View file

@ -0,0 +1,116 @@
# The WSL2 boot process
This page describes the steps in the WSL2 process, from the user invoking [wsl.exe](wsl.exe.md) to the user's Linux shell (bash in this example), in the WSL2 distribution.
## Overview
The below diagram shows the sequence of event to start bash within a WSL2 distribution. See [WSL architecture](index.md) for details about what each process does.
```mermaid
sequenceDiagram
wsl.exe->>wslservice.exe: CreateInstance(<distro>)
wslservice.exe->>wsl.exe: S_OK
wsl.exe->>wslservice.exe: CreateLxProcess(<distro>, <command line>, <env>, ...)
create participant mini_init
wslservice.exe->>mini_init: LxMiniInitMessageEarlyConfig
create participant gns
mini_init-->>gns: fork(), exec("/gns")
wslservice.exe->>gns: LxGnsMessageInterfaceConfiguration
gns->>wslservice.exe: LxGnsMessageResult
wslservice.exe->>mini_init: LxMiniInitMessageInitialConfig
wslservice.exe->>mini_init: LxMiniInitMessageLaunchInit
create participant init
mini_init-->>init: fork(), exec("/init")
init->>wslservice.exe: LxMiniInitMessageCreateInstanceResult
wslservice.exe->>init: LxInitMessageCreateSession
create participant session leader
init-->>session leader: fork()
session leader->>wslservice.exe: LxInitMessageCreateSessionResponse
wslservice.exe->>session leader: InitCreateProcessUtilityVm
create participant relay
session leader-->>relay: fork()
relay->>wslservice.exe: LxMessageResultUint32 (hvsocket connect port)
wslservice.exe->>relay: connect hvsockets for STDIN, STDOUT, STDERR
create participant bash
relay-->>bash: fork(), exec("/bin/bash")
relay<<-->>bash: relay STDIN, STDOUT, STDERR
wslservice.exe-->>wsl.exe: S_OK + hvsockets for STDIN, STDOUT, STDERR
wsl.exe<<->>relay: Relay STDIN, STDOUT, STDERR
destroy bash
relay-->>bash: waitpid()
relay->>wsl.exe: LxInitMessageExitStatus (process exit code)
```
## CreateInstance()
When [wslervice.exe](wslservice.exe.md) receives the CreateInstance() call via COM, it will:
1) Identify which distribution the user wants to create. This is done by looking up the `DistributionRegistration` (see `src/windows/service/exe/DistributionRegistration.cpp`) in the Windows registry, matching either on the distribution ID, or using the default if none is provided.
2) Based on the type of distribution (WSL1 or WSL2), either create a WSL1 instance, or start up a WSL2 virtual machine.
3) Associate the newly creating distribution to the calling process (see `src/windows/service/exe/Lifetime.cpp`)
## Starting the WSL2 virtual machine
To start a WSL2 distribution, [wslservice.exe](wslservice.exe.md) needs a virtual machine. If the virtual machine isn't already running, it will be created as part of the `CreateInstance()` call.
The WSL2 virtual machine is created via the [Host Compute System (HCS) service](https://learn.microsoft.com/virtualization/api/hcs/overview) (see `src/windows/service/exe/WslCoreVm.cpp`).
To create a new virtual machine, [wslservice.exe](wslservice.exe.md) generates a JSON string, which describes the virtual machine configuration. This JSON is then passed to [HcsCreateComputeSystem()](https://learn.microsoft.com/virtualization/api/hcs/reference/hcscreatecomputesystem) to create a new virtual machine.
See `src/windows/common/hcs_schema.h` for more details on the HCS JSON schema.
Part of the JSON configuration includes:
- The kernel: WSL will use its built-in kernel, usually installed `C:/Program Files/WSL/tools/kernel`, or a custom kernel if overridden via [.wslconfig](https://learn.microsoft.com/windows/wsl/wsl-config)
- The initramfs: WSL uses its own initramfs (usually installed in `C:\Program Files\WSL\tools\initrd.img`). It's an image that only contains the [mini_init](mini_init.md) binary
- The resources accessible to the virtual machine such as CPU, RAM, GPU, etc
When started, the virtual machine will boot into the provided kernel, and then execute [mini_init](mini_init.md).
## The Linux boot process
[mini_init](mini_init.md) is the process that performs usermode initialization inside the virtual machine. After performing various configurations, `mini_init` receives a `LxMiniInitMessageEarlyConfig` message from the [wslservice.exe](wslservice.exe.md) which contains the following information:
- Identifiers for the system VHD, swap VHD and kernel modules VHD if any
- The machine's hostname
- The configured memory reclaim mode and page reporting order(See [wsl2.pageReporting](https://learn.microsoft.com/windows/wsl/wsl-config))*
[mini_init](mini_init.md) then creates the [gns process](gns.md), which is responsible for networking configuration and then receives a `LxMiniInitMessageInitialConfig` message, which contains:
- An entropy buffer, to seed the virtual machine's entropy
- Information about the GPU drivers shares to mount, if any
- Wether [wslg](https://github.com/microsoft/wslg) is enabled
After applying all the configuration requested by [wslservice.exe](wslservice.exe.md), the virtual machine is ready to start Linux distributions.
## Starting a Linux distribution
To start a new distribution, [wslservice.exe](wslservice.exe.md) sends a `LxMiniInitMessageLaunchInit` message to [mini_init](mini_init.md), which then mounts the distribution vhd and starts [init](init.md). See ([init](init.md) for more details on WSL2 distributions configuration)
Once running, [wslservice.exe](wslservice.exe.md) can then send a `LxInitMessageCreateSession` message to start a new [session leader](session-leader.md) inside that distribution, which can be used to launch linux processes
## Relaying the linux process's input and output to Windows
Once the user's linux process has been created, [wslservice.exe](wslservice.exe.md) can return from `CreateLxProcess()` back to [wsl.exe](wsl.exe.md). In the case of WSL2, [wsl.exe](wsl.exe.md) receives the following HANDLES:
- STDIN
- STDOUT
- STDERR
- Control channel
- Interop channel
The `STDIN`, `STDOUT` and `STDERR` handles are used to relay input and output from the Linux process to the Windows terminal. Depending on the type of handle (terminal, pipe, file, ...), [wsl.exe](wsl.exe.md) will apply different relaying logics (see `src/windows/common/relay.cpp`) to achieve the best compatibility between Windows & Linux.
The `Control channel` is used to notify the linux process of a change in the terminal (for instance when [wsl.exe's](wsl.exe.md) terminal window is resized) so these changes can be applied to the Linux process as well.
The `Interop channel` has two usages:
- Create Windows processes from Linux (see [interop](interop.md))
- Notify [wsl.exe](wsl.exe.md) when the Linux process has exited (see `LxInitMessageExitStatus`)
Once the Linux process has exited, [wsl.exe](wsl.exe.md) flushes all remaining IO, and exits with the same exit code as the Linux process.
If [wsl.exe](wsl.exe.md) is terminated before the Linux process exits, [wslhost.exe](wslhost.exe.md) will take over the `Interop channel` and continue to handle requests to execute Windows processes.

View file

@ -0,0 +1,35 @@
# Accessing Windows drives from Linux
WSL offers mountpoints to access Windows drives from Linux. These mountpoints are mounted under `/mnt` by default, and point to the root of Windows drives.
## Elevated vs non-elevated mountpoints
Within a distribution, WSL separates between Linux processes that have been created from an elevated (as in administrator level) and from a non-elevated (user level) context.
This is done by having two separate [mount namespaces](https://man7.org/linux/man-pages/man7/mount_namespaces.7.html) within the distribution. One of them offers an elevated access to Windows drives, and the other offers a non-elevated access to Windows drives.
When a Linux process is created, [wslservice.exe](wslservice.exe.md) determines its elevation status, and then tell [init](init.md) to create the process in the appropriate mount namespace.
## Mounting a Windows drive
*Note: This section only applies to WSL2 distributions. *
When a [session leader](session-leader.md) is created, [wslsevice.exe](wslservice.exe.md) starts a [plan9](https://9fans.github.io/plan9port/man/man9/intro.html) file server. This file server can be connected to from the WSL2 virtual machine to mount Windows drives.
When the WSL distribution is created, [wslservice.exe](wslservice.exe.md) uses the `LX_INIT_CONFIGURATION_INFORMATION` message to indicate wether the process that created the distribution is elevated or not. Based on this, [init](init.md) will mount either or the elevated, or un-elevated version of the plan9 server.
Later when the first command is created in the namespace that hasn't been mounted yet, (either elevated, or non-elevated), [wslservice.exe](wslservice.exe.md) sends a `LxInitMessageRemountDrvfs` to [init](init.md), which tell `init` to mount the other namespace.
See: `src/windows/service/exe/WslCoreInstance.cpp` and `src/linux/drvfs.cpp`.
## Mounting a drive from Linux
As long as the Windows plan9 server is running, drives can be mounted simply by calling [mount](https://linux.die.net/man/8/mount). For instance mounting the C: drive manually can be done via:
```
mount -t drvfs C: /tmp/my-mount-point
```
Internally, this handled by `/usr/sbin/mount.drvfs`, which is a symlink to `/init`. When `/init` starts, it looks at `argv[0]` to determine which entrypoint to run. If `argv[0]` is `mount.drvfs`, then `/init` runs the `mount.drvfs` entrypoint (see `MountDrvfsEntry()` in `src/linux/init/drvfs.cpp`).
Depending on the distribution configuration, `mount.drvfs` will either mount the drive as `drvfs` (WSL1), or `plan9`, `virtio-plan9` or `virtiofs` (WSL), depending on [.wslconfig](https://learn.microsoft.com/windows/wsl/wsl-config).

View file

@ -0,0 +1,16 @@
# GNS
`gns` is a process created by `mini_init`. Its jobs is to configure networking within the WSL2 virtual machine.
## Networking configuration
Networking settings are shared by all WSL2 distributions. While WSL2 is running, `gns` maintains an hvsocket channel to [wslservice.exe](wslservice.exe.md), which is used to send various networking related configurations such as:
- Interface IP configuration
- Routing table entries
- DNS configuration
- MTU size configuration
When DNS tunneling is enabled, `gns` is also responsible for replying to DNS requests.
See `src/linux/init/GnsEngine.cpp` and `src/windows/service/exe/GnsChannel.cpp`

View file

@ -0,0 +1,46 @@
# WSL Overview
WSL is comprised of a set of executables, API's and protocols. This page offers an overview of the different components, and how they're connected.
Click on any component to get more details.
```mermaid
%%{ init: {
'flowchart': { 'curve': 'stepBefore' },
'theme': 'neutral'
}
}%%
graph
subgraph Windows["<b><p style="font-size:30px">Windows</p></b>"]
C:\Windows\System32\wsl.exe["C:\Windows\System32\wsl.exe"]---|"CreateProcess()"|wsl.exe;
wsl.exe[<a href="wsl.exe">wsl.exe</a>]---|COM|wslservice.exe;
wslg.exe[<a href="wslg.exe">wslg.exe</a>]---|COM|wslservice.exe;
wslconfig.exe[<a href="wslconfig.exe">wslconfig.exe</a>]---|COM|wslservice.exe;
wslapi.dll[<a href="https://learn.microsoft.com/windows/win32/api/wslapi/">wslapi.dll</a>]---|COM|wslservice.exe;
id[debian.exe, ubuntu.exe, ]---|"LoadLibrary()"|wslapi.dll;
wslservice.exe[<a href="wslservice.exe">wslservice.exe</a>]---|"CreateProcessAsUser()"|wslrelay.exe[<a href="wslrelay.exe">wslrelay.exe</a>];
wslservice.exe---|"CreateProcessAsUser()"|wslhost.exe[<a href="wslhost.exe">wslhost.exe</a>];
fs["Windows filesystem (//wsl.localhost)"]
end
wslservice.exe -----|hvsocket| mini_init
wslservice.exe -----|hvsocket| gns
fs---|hvsocket|plan9
wsl.exe---|hvsocket|relay
subgraph Linux["<b><p style="font-size:30px">Linux</p></b>"]
mini_init[<a href="mini_init">mini_init</a>]---|"exec()"|gns[<a href="gns">gns</a>]
mini_init---|"exec()"|init[<a href="init">init</a>];
mini_init---|"exec()"|localhost[<a href="localhost">localhost</a>];
subgraph "Linux Distribution"["<b><p style="font-size:23px">Linux Distribution</p></b>"]
init[<a href="init">init</a>]---|"exec()"|plan9[<a href="plan9">plan9</a>];
init---|"exec()"|sid[session leader];
sid[<a href="session-leader">session leader</a>]---|"exec()"|relay
relay[<a href="relay">relay</a>]---|"exec()"|cid["User command (bash, curl)"]
end
end
```

View file

@ -0,0 +1,36 @@
# Init
Init is top level process of a WSL distribution. For WSL1 distributions, it is launched by [wslservice](wslservice.exe.md) (see `src/windows/service/LxssInstance.cpp`) and for WSL2 distributions, it is launched by [mini_init](mini_init.md).
## WSL2 specific distributions startup
Each WSL2 distributions runs in a separate mount, pid and UTS namespace. This allows distributions to run in parallel, without "seeing" each other.
When a WSL2 distribution starts, [mini_init](mini_init.md):
- Mounts the distribution VHD
- Clones into a child namespace
- Chroots in the VHD mountpoint
- Executes init (see the `LxMiniInitMessageLaunchInit` message).
While each distribution runs in its own mount namespace, the `/mnt/wsl` mountpoint is shared between all distributions.
## Distribution initialization
Once started, the `init` process performs various initialization tasks such as:
- Mounting `/proc`, `/sys` and `/dev`
- Configuring cgroups
- Registering the binfmt interpreter (see [interop](interop.md))
- Parsing [/etc/wsl.conf](https://learn.microsoft.com/windows/wsl/wsl-config)
- Starting systemd (see [systemd](systemd.md))
- Mounting `drvfs` drives (See [drvfs](drvfs.md))
- Configuring `wslg` (see [wslg](https://github.com/microsoft/wslg))
## Running the distribution
Once ready, `init` establishes either an `lxbus` (WSL1) or an `hvsocket` (WSL2) connection to [wslservice](wslservice.exe.md). This channel is used to transmit various commands to `init` (see `src/shared/inc/lxinitshared.h`), such as:
- `LxInitMessageInitialize`: Configure the distribution
- `LxInitMessageCreateSession`: Create a new session leader. See [session leader](session-leader.md)
- `LxInitMessageTerminateInstance`: Terminate the distribution

View file

@ -0,0 +1,30 @@
# Running Windows executables from Linux
The ability to launch Windows processes from Linux is controlled by 2 different levels of settings:
- The `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LxssManager\DistributionFlags` registry value, which control the settings for all Windows users (setting the lowest significance bit disables interop)
- The `[interop]` section in [/etc/wsl.conf](https://learn.microsoft.com/windows/wsl/wsl-config#wslconf), which controls the setting for a given WSL distribution
## binfmt interpreters for Windows executables
To allow Windows process creation from Linux, WSL registers a [binfmt interpreter](https://docs.kernel.org/admin-guide/binfmt-misc.html), which tells the kernel to execute an arbitrary command when a specific type of executable is launched via `exec*()` system calls.
To perform the registration, WSL writes to `/proc/sys/fs/binfmt_misc` and creates a `WSLInterop` entry, which points to `/init`. For WSL1 registration, the entry is written by [init](init.md) for each distribution, for WSL2 [mini_init](mini_init.md) registers the binfmt interpreter at the virtual machine level.
Note: The `/init` executable is the entrypoint for different WSL processes ([init](init.md), [plan9](plan9.md), [localhost](localhost.md), etc). This executable looks at `argv[0]` to determine which logic to run. In the case of interop, `/init` will run the Windows process creation logic of its `argv[0]` value doesn't match any of the known entrypoints.
See: `WslEntryPoint()` in `src/linux/init.cpp`.
## Connecting to interop servers
When the user tries to execute a Windows process, the kernel will launch `/init` with the Windows process's command line as arguments.
To start a new Windows process `/init` needs to connect to an interop server. Interop servers are Linux processes that have an hvsocket connection to Windows processes (either [wsl.exe](wsl.exe.md) or [wslhost.exe](wslhost.exe.md) processes) and that can launch Windows executables.
Inside Linux, each [session leader](session-leader.md), and each instance of [init](init.md) has an associated interop server, which is serving via an unix socket under `/run/WSL`.
`/init` uses the `$WSL_INTEROP` environment variable to know which server to connect to. If the variable is not set, `/init` will try to connect to `/run/WSL/${pid}_interop`, with its own PID. If that doesn't work, `/init` will try its parent's pid, and then will continue to go up the chain until it reached [init](init.md).
Once connected `/init` sends a `LxInitMessageCreateProcess` (WSL1) or a `LxInitMessageCreateProcessUtilityVm` (WSL2), which then forwards that message to the associated Windows process, which will launched the requested command and relay its output to `/init`.
See `src/linux/init/binfmt.cpp`

View file

@ -0,0 +1,14 @@
# Localhost
`localhost` is a WSL2 linux process, created by [mini_init](mini_init.md). Its role is to forward network traffic between the WSL2 virtual machine, and Windows.
## NAT networking
When `wsl2.networkingMode` is set to NAT, `localhost` will watch for bound TCP ports, and relay the network traffic to Windows via [wslrelay.exe](wslrelay.exe.md)
## Mirrored networking
In mirrored mode, `localhost` register a BPF program to intercept calls to `bind()`, and forward the calls to Windows via [wslservice.exe](wslservice.exe.md) so Windows can route the network traffic directly to the WSL2 virtual machine.
See `src/linux/localhost.cpp`.

View file

@ -0,0 +1,36 @@
# mini_init
mini_init is the first executable that's launched when the WSL2 virtual machine starts. See [WSL2 boot process](boot-process.md) for more details.
## Virtual machine setup
mini_init is started when the kernel is done booting, and calls `/init`, which is `mini_init`. Like other standard linux `init` executables, `mini_init` starts by mounting `/proc`, `/sys`, `/dev` and other standard mountpoints.
`mini_init` then performs various configuration such as enabling crash dump collection, configuring logging via `/dev/console` and tty configuration.
Once everything is ready, `mini_init` connects two hvsockets to [wslservice](wslservice.exe.md).
One of them, called the "mini_init" channel is used for messages sent by `wslservice.exe`. See `src/shared/inc/lxinitshared.h` for a list of messages and responses. Common messages are:
- `LxMiniInitMessageLaunchInit`: Mount a virtual disk and start a new distribution. See [`init`](init.md) for more details
- `LxMiniInitMessageMount`: Mount a disk in `/mnt/wsl` (used for wsl --mount)
- `EJECT_VHD_MESSAGE`: Eject a disk
- `LxMiniInitMessageImport`: Import a distribution
- `LxMiniInitMessageExport`: Export a distribution
The other hvsocket channel is used to send notifications to [wslservice.exe](wslservice.exe.md). This is used mainly to report when linux processes exit (which wslservice uses to know when distributions are terminated).
## Networking configuration
As part of the boot process, `mini_init` also launches the [gns binary](gns.md) which managed networking configuration
## Other tasks
`mini_init` performs various other maintenance tasks such as:
- Reclaiming unused memory
- Launching the debug shell tty
- Synchronizing IO when the virtual machine terminates
- Resizing filesystem (for wsl --manage <distro> --resize)
- Formatting disks (used when installing new distributions)

View file

@ -0,0 +1,19 @@
# Plan 9
Plan9 is a linux process that hosts a plan9 filesystem server for WSL1 and WSL2 distributions. It's created by [init](init.md) in each distribution.
## WSL 1
In WSL1 distributions, `plan9` serves its filesystem through a unix socket, which can then be connected to from Windows.
## WSL2
In WSL2 distributions, `plan9` runs its filesystem through an `hvsocket`
## Accessing the distribution files from Windows
From Windows, a special redirector driver (p9rdr.sys) registers both `\\wsl$` and `\\wsl.localhost`. When either of those paths are accessed, `p9rdr.sys` calls [wslservice.exe](wslservice.exe.md) to list the available distributions for a given Windows users.
When a distribution path is accessed (like `\\wsl.localhost\debian`), `p9rdr.sys` calls into [wslservice.exe](wslservice.exe.md) via COM to start the distribution, and connect to its plan9 server, which allows the files to be accessed from Windows.
See `src/linux/init/plan9.cpp`

View file

@ -0,0 +1,18 @@
# Relay
Relay is a WSL2 linux process creating by a [session leader](session-leader.md). Its job is to create a linux process on behalf of the user, and relay its output back to Windows.
## Creating a user process
A relay is created when a `LxInitMessageCreateProcessUtilityVm` message is sent to a [session leader](session-leader.md). Once created, the `relay` creates multiple `hvsocket` channels with [wslservice.exe](wslservice.exe.md).
These channels are used to:
- Relay standard file descriptors (stdin, stdout, stderr)
- Relay information about the terminal (for instance when the terminal window is resized from Windows)
- Notify Windows when the linux process exits
Once those channels are configured, the `relay` forks() into two processes:
- The parent, which will read & write to the child's standard file descriptors and relay it to Windows
- The child, which calls `exec()` and starts the user process

View file

@ -0,0 +1,26 @@
# Session leader
A session leader is a linux process, which is forked from [init](init.md) after receiving a `LxInitMessageCreateSession` message (see `src/linux/init.cpp`)
## Creating linux processes
Session leaders are used to create linux processes on behalf of the user. Each linux session leader is associated to a Windows console.
To create a user process, [wslservice.exe](wslservice.exe.md) sends a `LxInitMessageCreateProcess` message (WSL1) or a `LxInitMessageCreateProcessUtilityVm` message (WSL2), which contains details about the process to create such as:
- Command line
- Current directory
- Environment variables
- User name
### Creating a WSL1 process
When running in a WSL1 distribution, the session leader forks(), and uses the child process to `exec()` into the user linux process. Before calling `exec()`, child configures various settings such as:
- The user and group id
- The current directory
- The standard file descriptors (stdin, stdout, stderr)
## Creating a WSL2 process
When running in a WSL2 distribution, the session leaders forks() to create a [relay](relay.md) process, which is responsible for creating the user process and relaying its output back to [wsl.exe](wsl.exe.md)

View file

@ -0,0 +1,23 @@
# Systemd
Systemd support for a WSL distribution can be enabled by setting the following in `/etc/wsl.conf`:
```
[boot]
systemd=true
```
When enabled, [init](init.md) will take launch `/sbin/init` (which points to systemd's init) when the distribution starts. One key difference when this setting is enabled is that [init](init.md) won't be pid 1 in the given distribution, since systemd's init requires running as pid 1, so [init](init.md) will fork(), and launch systemd in the parent while continuing WSL configuration in the child process.
After launching `/sbin/init`, [init](init.md) waits for systemd to be ready by waiting for `systemctl is-system-running` to return either `running`, or `degraded`. After a given amount of time, WSL will time out and allow the distribution to continue starting, even if systemd isn't ready.
## User sessions
When systemd is enabled, WSL tries synchronizes launching processes with systemd user sessions. This is currently done by launching `login -f <user>` to start the associated systemd user session.
## Additional systemd configuration
To improve compatibility with systemd, WSL creates various systemd configuration files during boot (under `/run`). These configurations files are used to:
- Protect the WSL [binfmt interpret](interop.md) from being deleted by `systemd-binfmt.service`
- Protect the X11 socket from being deleted by `systemd-tmpfiles.serviceè

View file

@ -0,0 +1,8 @@
# wsl.exe
wsl.exe is main command line entrypoint from WSL. Its job is to:
- Parse the command line arguments (See `src/windows/common/wslclient.cpp`)
- Call [wslservice.exe](wslservice.exe.md) via COM to launch WSL (see `src/windows/common/svccomm.cpp`)
- Relay stdin / stdout / stderr from and to the linux process

View file

@ -0,0 +1,3 @@
# Wslconfig.exe
`wslconfig.exe` is a Windows executable that can be used to configure WSL distributions.

View file

@ -0,0 +1,5 @@
# Wslg.exe
`wslg.exe` is a Windows executable that is used mostly to run graphical applications with WSL.
Its behavior is exactly the same as [wsl.exe](wsl.exe.md) with the difference that it's a win32 application, and not a console application, which allows is to start without a creating a console.

View file

@ -0,0 +1,23 @@
# Wslhost.exe
`wslhost.exe` is a Windows executable that's used to display desktop notifications, and run Linux processes in the background.
## COM server
When running as COM server, `wslhost.exe` registers a [NotificationActivatorFactory](https://learn.microsoft.com/dotnet/api/microsoft.toolkit.uwp.notifications.notificationactivator?view=win-comm-toolkit-dotnet-7.1), which is then used to display desktop notifications to the user.
Notifications can be used to:
- Notify the user about a WSL update
- Warn the user about a configuration error
- Notify the user about a proxy change
See: `src/windows/common/notifications.cpp`
## Background processes
When [wsl.exe](wsl.exe.md) terminates before the associated Linux processes terminates, `wslhost.exe` takes over the lifetime of the Linux process.
This allows Linux processes to keep running Windows commands and access the terminal even after the associated `wsl.exe` terminates.
See `src/windows/wslhost/main.cpp` and [interop](interop.md)

View file

@ -0,0 +1,10 @@
# Wslrelay.exe
`wslrelay.exe` is a windows executable that is used to relay network and debug console traffic from Linux to Windows.
It is responsible for:
- Relaying localhost traffic between Linux and Windows in NAT mode (see [localhost](localhost.md))
- Displaying the debug console output when `wsl2.debugConsole` is set to `true`
See `src/windows/wslrelay/main.cpp`

View file

@ -0,0 +1,33 @@
# wslservice.exe
WslService is a session 0 service, running as SYSTEM. Its job is to manage WSL sessions, communicate with the WSL2 virtual machine and configure WSL distributions.
## COM Interface
Clients can connect to WslService via its COM interface, ILxssUserSession. Its definition can be found in `src/windows/service/incwslservice.idl`.
When a COM client calls [CoCreateInstance()](https://learn.microsoft.com/windows/win32/api/combaseapi/nf-combaseapi-cocreateinstance) on this interface, the service receives the requests via `LxssUserSessionFactory` (see `src/windows/service/LxssUserSessionFactory.cpp`) and returns an instance of `LxssUserSession` (see `src/windows/service/LxssUserSession.cpp`) per Windows user (calling CoCreateInstance() multiple times from the same Windows user accounts returns the same instance).
The client can then use its `ILxssUserSession` instance to call methods into the service, such as:
- `CreateInstance()`: Launch a WSL distribution
- `CreateLxProcess()`: Launch a process inside a distribution
- `RegisterDistribution()`: Register a new WSL distribution
- `Shutdown()`: Terminate all WSL distributions
## WSL2 Virtual machine
WslService manages the WSL2 Virtual Machine. The virtual machine management logic can be found in `src/windows/service/WslCoreVm.cpp`.
Once booted, WslService maintains an [hvsocket](https://learn.microsoft.com/virtualization/hyper-v-on-windows/user-guide/make-integration-service) with the Virtual Machine which it uses to send various commands to Linux processes (see [mini_init](mini_init.md) for more details.
## WSL2 Distributions
Once the virtual machine is running, WSL distributions can be started by calling `WslCoreVm::CreateInstance`. Each running distribution is represented by a `WslCoreInstance` (see `src/windows/service/WslCoreInstance.cpp`).
Each `WslCoreInstance` maintains an hvsocket connection to [init](init.md) which allows WslService to perform various tasks such as:
- Launching processes inside the distribution
- Be notified when the distribution exits
- Mount drvfs shares (/mnt/*)
- Stop the distribution

38
doc/mkdocs.yml Normal file
View file

@ -0,0 +1,38 @@
site_name: WSL
nav:
- 'Home': 'index.md'
- 'Getting started':
- 'Building and testing WSL': 'dev-loop.md'
- 'Debugging WSL': 'debugging.md'
- 'WSL architecture':
- 'Overview': technical-documentation/index.md
- 'wsl.exe': technical-documentation/wsl.exe.md
- 'wslg.exe': technical-documentation/wslg.exe.md
- 'wslconfig.exe': technical-documentation/wslconfig.exe.md
- 'wslhost.exe': technical-documentation/wslhost.exe.md
- 'wslrelay.exe': technical-documentation/wslrelay.exe.md
- 'wslservice.exe': technical-documentation/wslservice.exe.md
- 'mini_init': technical-documentation/mini_init.md
- 'init': technical-documentation/init.md
- 'session leader': technical-documentation/session-leader.md
- 'relay': technical-documentation/relay.md
- 'gns': technical-documentation/gns.md
- 'localhost': technical-documentation/localhost.md
- 'plan9': technical-documentation/plan9.md
- 'Technical documentation':
- 'Boot process': technical-documentation/boot-process.md
- 'Interop': technical-documentation/interop.md
- 'Drvfs & Plan9': technical-documentation/drvfs.md
- 'Systemd': technical-documentation/systemd.md
plugins:
- search
- mermaid2:
version: 11.4.1
arguments:
securityLevel: 'loose'
theme:
name: readthedocs

175
intune/WSL.admx Normal file
View file

@ -0,0 +1,175 @@
<policyDefinitions revision="1.0" schemaVersion="1.0">
<policyNamespaces>
<target prefix="WSL" namespace="Microsoft.WSL" />
<using prefix="windows" namespace="Microsoft.Policies.Windows" />
</policyNamespaces>
<resources minRequiredRevision="0.1" fallbackCulture="en-US"/>
<categories>
<category name="WSL" displayName="$(string.WindowsSubsystemForLinux)"/>
</categories>
<policies>
<policy name="AllowWSL" class="Machine" displayName="$(string.AllowWSL)" explainText="$(string.AllowWSLExplain)" key="Software\Policies\WSL" valueName="AllowWSL">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="AllowInboxWSL" class="Machine" displayName="$(string.AllowInboxWSL)" explainText="$(string.AllowInboxWSLExplain)" key="Software\Policies\WSL" valueName="AllowInboxWSL">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="AllowWSL1" class="Machine" displayName="$(string.AllowWSL1)" explainText="$(string.AllowWSL1Explain)" key="Software\Policies\WSL" valueName="AllowWSL1">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="CustomKernelUserSettingConfigurable" class="Machine" displayName="$(string.CustomKernelUserSettingConfigurable)" explainText="$(string.CustomKernelExplain)" key="Software\Policies\WSL" valueName="AllowKernelUserSetting">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="CustomSystemDistroUserSettingConfigurable" class="Machine" displayName="$(string.CustomSystemDistroUserSettingConfigurable)" explainText="$(string.CustomSystemDistroExplain)" key="Software\Policies\WSL" valueName="AllowSystemDistroUserSetting">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="CustomKernelCommandLineUserSettingConfigurable" class="Machine" displayName="$(string.CustomKernelCommandLineUserSettingConfigurable)" explainText="$(string.CustomKernelCommandLineExplain)" key="Software\Policies\WSL" valueName="AllowKernelCommandLineUserSetting">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="AllowDebugShell" class="Machine" displayName="$(string.AllowDebugShell)" explainText="$(string.AllowDebugShellExplain)" key="Software\Policies\WSL" valueName="AllowDebugShell">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="NestedVirtualizationUserSettingConfigurable" class="Machine" displayName="$(string.NestedVirtualizationUserSettingConfigurable)" explainText="$(string.NestedVirtualizationExplain)" key="Software\Policies\WSL" valueName="AllowNestedVirtualization">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="KernelDebugUserSettingConfigurable" class="Machine" displayName="$(string.KernelDebugUserSettingConfigurable)" explainText="$(string.KernelDebugExplain)" key="Software\Policies\WSL" valueName="AllowKernelDebugUserSetting">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="CustomNetworkingUserSettingConfigurable" class="Machine" displayName="$(string.CustomNetworkingUserSettingConfigurable)" explainText="$(string.CustomNetworkingExplain)" key="Software\Policies\WSL" valueName="AllowNetworkingModeUserSetting">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="FirewallUserSettingConfigurable" class="Machine" displayName="$(string.FirewallUserSettingConfigurable)" explainText="$(string.FirewallExplain)" key="Software\Policies\WSL" valueName="AllowFirewallUserSetting">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="AllowDiskMount" class="Machine" displayName="$(string.AllowDiskMount)" explainText="$(string.AllowDiskMountExplain)" key="Software\Policies\WSL" valueName="AllowDiskMount">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="DefaultNetworkingMode" class="Machine" displayName="$(string.DefaultNetworkingMode)" explainText="$(string.DefaultNetworkingModeExplain)" presentation="$(presentation.DefaultNetworkingMode)" key="Software\Policies\WSL" valueName="DefaultNetworkingMode">
<parentCategory ref="WSL" />
<supportedOn ref="windows:SUPPORTED_Windows10" />
<elements>
<enum id="DefaultNetworkingMode_Dropdown" valueName="DefaultNetworkingMode">
<item displayName="$(string.NetworkingModeNone)">
<value>
<decimal value="0" />
</value>
</item>
<item displayName="$(string.NetworkingModeNAT)">
<value>
<decimal value="1" />
</value>
</item>
<!-- Bridged networking is intentionally left out because it requires additional configuration -->
<item displayName="$(string.NetworkingModeMirrored)">
<value>
<decimal value="3" />
</value>
</item>
<item displayName="$(string.NetworkingModeVirtioProxy)">
<value>
<decimal value="4" />
</value>
</item>
</enum>
</elements>
</policy>
</policies>
</policyDefinitions>

59
intune/en-US/WSL.adml Normal file
View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- (c) 2006 Microsoft Corporation -->
<policyDefinitionResources xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="0.1" schemaVersion="0.1" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<displayName>WSL</displayName>
<description>Windows Subsystem for Linux</description>
<resources>
<stringTable>
<string id="WindowsSubsystemForLinux">Windows Subsystem For Linux</string>
<string id="AllowWSL">Allow the Windows Subsystem For Linux</string>
<string id="AllowWSLExplain">When set to disabled, this policy disables access to the Windows Subsystem For Linux for all users on the machine.</string>
<string id="AllowInboxWSL">Allow the Inbox version of the Windows Subsystem For Linux</string>
<string id="AllowInboxWSLExplain">When set to disabled, this policy disables the inbox version (optional component) of the Windows Subsystem For Linux. If this policy is disabled, only the store version of WSL can be used.</string>
<string id="AllowWSL1">Allow WSL1</string>
<string id="AllowWSL1Explain">When set to disabled, this policy disables WSL1. When disabled, only WSL2 distributions can be used.</string>
<string id="CustomKernelUserSettingConfigurable">Allow custom kernel configuration</string>
<string id="CustomKernelExplain">When set to disabled, this policy disables custom kernel configuration via .wslconfig (wsl2.kernel). This policy only applies to Store WSL.</string>
<string id="CustomSystemDistroUserSettingConfigurable">Allow custom system distribution configuration</string>
<string id="CustomSystemDistroExplain">When set to disabled, this policy disables custom system distribution configuration via .wslconfig (wsl2.systemDistro). This policy only applies to Store WSL.</string>
<string id="CustomKernelCommandLineUserSettingConfigurable">Allow kernel command line configuration</string>
<string id="CustomKernelCommandLineExplain">When set to disabled, this policy disables kernel command line configuration via .wslconfig (wsl2.kernelCommandLine). This policy only applies to Store WSL.</string>
<string id="AllowDebugShell">Allow the debug shell</string>
<string id="AllowDebugShellExplain">When set to disabled, this policy disables the debug shell (wsl.exe --debug-shell). This policy only applies to Store WSL.</string>
<string id="NestedVirtualizationUserSettingConfigurable">Allow nested virtualization</string>
<string id="NestedVirtualizationExplain">When set to disabled, this policy disables nested virtualization configuration via .wslconfig (wsl2.nestedVirtualization). This policy only applies to Store WSL.</string>
<string id="KernelDebugUserSettingConfigurable">Allow kernel debugging</string>
<string id="KernelDebugExplain">When set to disabled, this policy disables kernel kernel debugging configuration via .wslconfig (wsl2.kernelDebugPort). This policy only applies to Store WSL.</string>
<string id="CustomNetworkingUserSettingConfigurable">Allow custom networking configuration</string>
<string id="CustomNetworkingExplain">When set to disabled, this policy disables custom networking configuration via .wslconfig (wsl2.networkingmode). This policy only applies to Store WSL.</string>
<string id="FirewallUserSettingConfigurable">Allow user setting firewall configuration</string>
<string id="FirewallExplain">When set to disabled, this policy disables firewall configuration via .wslconfig (wsl2.firewall). This policy only applies to Store WSL.</string>
<string id="AllowDiskMount">Allow passthrough disk mount</string>
<string id="AllowDiskMountExplain">When set to disabled, this policy disables passthrough disk mounting in WSL2 (wsl.exe --mount). This policy only applies to Store WSL.</string>
<string id="DefaultNetworkingMode">Configure default networking mode</string>
<string id="DefaultNetworkingModeExplain">This policy specifies the default networking mode to be used for WSL2.</string>
<string id="NetworkingModeNone">None</string>
<string id="NetworkingModeNAT">NAT</string>
<string id="NetworkingModeMirrored">Mirrored</string>
<string id="NetworkingModeVirtioProxy">VirtioProxy</string>
</stringTable>
<presentationTable>
<presentation id="DefaultNetworkingMode">
<dropdownList refId="DefaultNetworkingMode_Dropdown" noSort="true" defaultItem="1">Default Networking Mode</dropdownList>
</presentation>
</presentationTable>
</resources>
</policyDefinitionResources>

View file

@ -0,0 +1,11 @@
set(LOCALIZATION_PS1 ${PROJECT_SOURCE_DIR}/tools/generateLocalizationHeader.ps1)
set (MESSAGESHEAD ${GENERATED_DIR}/Localization.h)
add_custom_command(
OUTPUT ${MESSAGESHEAD} ${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/localization
COMMAND powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive ${LOCALIZATION_PS1} -OutFile ${MESSAGESHEAD}
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/localization"
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/strings/en-US/Resources.resw ${LOCALIZATION_PS1} # Make sure the head file is rebuilt if any of the resources change
VERBATIM
)
add_custom_target(localization DEPENDS ${MESSAGESHEAD} ${LOCALIZATION_PS1} SOURCES ${CMAKE_CURRENT_LIST_DIR}/strings/en-US/Resources.resw)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more