2017-04-18 22:12:35 +02:00
|
|
|
# Build PowerShell on macOS
|
2016-03-30 23:30:13 +02:00
|
|
|
|
|
|
|
This guide supplements the [Linux instructions](./linux.md), as
|
2016-08-26 21:08:50 +02:00
|
|
|
building on macOS is almost identical.
|
2016-03-30 23:30:13 +02:00
|
|
|
|
2019-11-24 13:41:53 +01:00
|
|
|
.NET Core 2.x (and by transitivity, us) only supports macOS 10.13+.
|
2016-04-14 20:25:09 +02:00
|
|
|
|
2017-04-18 22:12:35 +02:00
|
|
|
## Environment
|
2016-03-30 23:30:13 +02:00
|
|
|
|
2019-10-10 00:02:05 +02:00
|
|
|
You will want [Homebrew](https://brew.sh/) or [MacPorts](https://www.macports.org/), the missing package manager for macOS.
|
2016-07-22 00:50:04 +02:00
|
|
|
Once installed, follow the same instructions to download and
|
2018-01-17 21:53:28 +01:00
|
|
|
install a self-hosted copy of PowerShell on your macOS machine.
|
|
|
|
From `pwsh.exe`, run `Import-Module ./build.psm1` and use `Start-PSBootstrap` to install the dependencies.
|
2016-03-30 23:30:13 +02:00
|
|
|
|
2016-04-14 01:21:23 +02:00
|
|
|
The `Start-PSBootstrap` function does the following:
|
2016-03-30 23:30:13 +02:00
|
|
|
|
2019-10-10 00:02:05 +02:00
|
|
|
- Uses `brew` or `port` to install CMake, OpenSSL, and GNU WGet
|
2016-06-11 01:06:08 +02:00
|
|
|
- Uninstalls any prior versions of .NET CLI
|
2018-08-31 01:51:52 +02:00
|
|
|
- Downloads and installs .NET Core SDK to `~/.dotnet`
|
2016-04-14 01:41:50 +02:00
|
|
|
|
2016-07-22 00:50:04 +02:00
|
|
|
If you want to use `dotnet` outside of `Start-PSBuild`,
|
|
|
|
add `~/.dotnet` to your `PATH` environment variable.
|
2016-03-30 23:30:13 +02:00
|
|
|
|
2017-04-18 22:12:35 +02:00
|
|
|
### error: Too many open files
|
2016-04-14 20:25:09 +02:00
|
|
|
|
2016-07-22 00:50:04 +02:00
|
|
|
Due to a [bug][809] in NuGet, the `dotnet restore` command will fail without the limit increased.
|
|
|
|
Run `ulimit -n 2048` to fix this in your session;
|
2017-04-18 22:12:35 +02:00
|
|
|
add it to your shell's profile to fix it permanently.
|
2016-04-14 20:25:09 +02:00
|
|
|
|
2016-08-18 19:47:23 +02:00
|
|
|
We cannot do this for you in the build module due to #[847][].
|
2016-04-14 20:25:09 +02:00
|
|
|
|
|
|
|
[809]: https://github.com/dotnet/cli/issues/809
|
|
|
|
[847]: https://github.com/PowerShell/PowerShell/issues/847
|
|
|
|
|
2017-04-18 22:12:35 +02:00
|
|
|
## Build using our module
|
2016-03-30 23:30:13 +02:00
|
|
|
|
2017-11-01 23:55:46 +01:00
|
|
|
Start a PowerShell session by running `pwsh`, and then use `Start-PSBuild` from the module.
|
2016-07-22 00:50:04 +02:00
|
|
|
|
2020-04-29 05:25:33 +02:00
|
|
|
After building, PowerShell will be at `./src/powershell-unix/bin/Debug/net5.0/osx-x64/publish/pwsh`.
|