mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +00:00
# PR Summary * remove explicit en-us from links * remove view parameter ## PR Context follow-up #7013 ## PR Checklist - [x] [PR has a meaningful title](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission) - Use the present tense and imperative mood when describing your changes - [x] [Summarized changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission) - [x] [Make sure all `.h`, `.cpp`, `.cs`, `.ps1` and `.psm1` files have the correct copyright header](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission) - [x] This PR is ready to merge and is not [Work in Progress](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---work-in-progress). - If the PR is work in progress, please add the prefix `WIP:` or `[ WIP ]` to the beginning of the title (the `WIP` bot will keep its status check at `Pending` while the prefix is present) and remove the prefix when the PR is ready. - **[Breaking changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes)** - [ ] None - **OR** - [ ] [Experimental feature(s) needed](https://github.com/MicrosoftDocs/PowerShell-Docs/blob/staging/reference/6/Microsoft.PowerShell.Core/About/about_Experimental_Features.md) - [ ] Experimental feature name(s): <!-- Experimental feature name(s) here --> - **User-facing changes** - [x] Not Applicable - **OR** - [ ] [Documentation needed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission) - [ ] Issue filed: <!-- Number/link of that issue here --> - **Testing - New and feature** - [x] N/A or can only be tested interactively - **OR** - [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting) - **Tooling** - [x] I have considered the user experience from a tooling perspective and don't believe tooling will be impacted. - **OR** - [ ] I have considered the user experience from a tooling perspective and enumerated concerns in the summary. This may include: - Impact on [PowerShell Editor Services](https://github.com/PowerShell/PowerShellEditorServices) which is used in the [PowerShell extension](https://github.com/PowerShell/vscode-powershell) for VSCode (which runs in a different PS Host). - Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features. - Impact on [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) (which provides linting & formatting in the editor extensions). - Impact on [EditorSyntax](https://github.com/PowerShell/EditorSyntax) (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
78 lines
2.7 KiB
Markdown
78 lines
2.7 KiB
Markdown
# Build PowerShell on Linux
|
|
|
|
This guide will walk you through building PowerShell on Linux.
|
|
We'll start by showing how to set up your environment from scratch.
|
|
|
|
## Environment
|
|
|
|
These instructions are written assuming the Ubuntu 16.04 LTS, since that's the distro the team uses.
|
|
The build module works on a best-effort basis for other distributions.
|
|
|
|
### Git Setup
|
|
|
|
Using Git requires it to be set up correctly;
|
|
refer to the [Working with the PowerShell Repository](../git/README.md),
|
|
[README](../../README.md), and [Contributing Guidelines](../../.github/CONTRIBUTING.md).
|
|
|
|
**This guide assumes that you have recursively cloned the PowerShell repository and `cd`ed into it.**
|
|
|
|
### Toolchain Setup
|
|
|
|
We use the [.NET Command-Line Interface][dotnet-cli] (`dotnet`) to build the managed components,
|
|
and [CMake][] to build the native components.
|
|
|
|
Installing the toolchain is as easy as running `Start-PSBootstrap` in PowerShell.
|
|
Of course, this requires a self-hosted copy of PowerShell on Linux.
|
|
|
|
Fortunately, this is as easy as [downloading and installing the package](https://docs.microsoft.com/powershell/scripting/install/installing-powershell-core-on-linux#binary-archives).
|
|
The `./tools/install-powershell.sh` script will also install the PowerShell package.
|
|
|
|
In Bash:
|
|
|
|
```sh
|
|
./tools/install-powershell.sh
|
|
|
|
pwsh
|
|
```
|
|
|
|
You should now be in a PowerShell console host that is installed.
|
|
Just import our module, bootstrap the dependencies, and build!
|
|
|
|
In PowerShell:
|
|
|
|
```powershell
|
|
Import-Module ./build.psm1
|
|
Start-PSBootstrap
|
|
```
|
|
|
|
The `Start-PSBootstrap` function does the following:
|
|
|
|
- Adds the LLVM package feed
|
|
- Installs our dependencies combined with the dependencies of the .NET CLI toolchain via `apt-get`
|
|
- Uninstalls any prior versions of .NET CLI
|
|
- Downloads and installs the .NET Core SDK 2.0.0 to `~/.dotnet`
|
|
|
|
If you want to use `dotnet` outside of `Start-PSBuild`, add `~/.dotnet` to your `PATH` environment variable.
|
|
|
|
[dotnet-cli]: https://github.com/dotnet/cli
|
|
[CMake]: https://cmake.org/cmake/help/v2.8.12/cmake.html
|
|
|
|
## Build using our module
|
|
|
|
We maintain a [PowerShell module](../../build.psm1) with the function `Start-PSBuild` to build PowerShell.
|
|
Since this is PowerShell code, it requires self-hosting.
|
|
If you have followed the toolchain setup section above, you should have PowerShell Core installed.
|
|
|
|
```powershell
|
|
Import-Module ./build.psm1
|
|
Start-PSBuild
|
|
```
|
|
|
|
Congratulations! If everything went right, PowerShell is now built.
|
|
The `Start-PSBuild` script will output the location of the executable:
|
|
|
|
`./src/powershell-unix/bin/Debug/net5.0/linux-x64/publish/pwsh`.
|
|
|
|
You should now be running the PowerShell Core that you just built, if your run the above executable.
|
|
You can run our cross-platform Pester tests with `Start-PSPester`, and our xUnit tests with `Start-PSxUnit`.
|