"Fossies" - the Fresh Open Source Software Archive

Member "PowerShell-7.2.5/docs/building/linux.md" (21 Jun 2022, 2711 Bytes) of package /linux/misc/PowerShell-7.2.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field. See also the last Fossies "Diffs" side-by-side code changes report for "linux.md": 7.2.1_vs_7.2.2.

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, README, and Contributing Guidelines.

This guide assumes that you have recursively cloned the PowerShell repository and cded into it.

Toolchain Setup

We use the .NET Command-Line Interface (dotnet) to build the managed 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. The ./tools/install-powershell.sh script will also install the PowerShell package.

In Bash:

./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:

Import-Module ./build.psm1
Start-PSBootstrap

The Start-PSBootstrap function does the following:

If you want to use dotnet outside of Start-PSBuild, add ~/.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. 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 you run the above executable. You can run our cross-platform Pester tests with Start-PSPester, and our xUnit tests with Start-PSxUnit.