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.
These instructions are written assuming the Ubuntu 14.04 LTS, since that's the distro the team uses. The build module works on a best-effort basis for other distributions.
This guide assumes that you have recursively cloned the PowerShell repository and
cded into it.
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.
./tools/install-powershell.sh script will also install the PowerShell package.
You should now be in a PowerShell console host that is installed. Just import our module, bootstrap the dependencies, and build!
Import-Module ./build.psm1 Start-PSBootstrap
Start-PSBootstrap function does the following:
- Adds the LLVM package feed
- Installs our dependencies combined with the dependencies of the .NET CLI toolchain via
- Uninstalls any prior versions of .NET CLI
- Downloads and installs the .NET Core SDK 2.0.0 to
If you want to use
dotnet outside of
~/.dotnet to your
PATH environment variable.
Build using our module
We maintain a PowerShell module 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.
Import-Module ./build.psm1 Start-PSBuild
Congratulations! If everything went right, PowerShell is now built.
Start-PSBuild script will output the location of the executable:
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