2017-04-19 04:12:35 +08:00
# Build PowerShell on macOS
2016-03-31 05:30:13 +08:00
This guide supplements the [Linux instructions ](./linux.md ), as
2016-08-27 03:08:50 +08:00
building on macOS is almost identical.
2016-03-31 05:30:13 +08:00
2017-04-19 04:12:35 +08:00
.NET Core 2.0 (and by transitivity, us) only supports macOS 10.12.
2016-04-15 02:25:09 +08:00
2017-04-19 04:12:35 +08:00
## Environment
2016-03-31 05:30:13 +08:00
2016-08-27 03:08:50 +08:00
You will want [Homebrew ](http://brew.sh/ ), the missing package manager for macOS.
2016-07-22 06:50:04 +08:00
Once installed, follow the same instructions to download and
2016-08-27 03:08:50 +08:00
install a self-hosted copy of PowerShell on your macOS machine,
2016-07-22 06:50:04 +08:00
and use`Start-PSBootstrap` to install the dependencies.
2016-03-31 05:30:13 +08:00
2016-04-14 07:21:23 +08:00
The `Start-PSBootstrap` function does the following:
2016-03-31 05:30:13 +08:00
2016-04-14 07:21:23 +08:00
- Uses `brew` to install CMake, OpenSSL, and GNU WGet
2016-06-11 07:06:08 +08:00
- Uninstalls any prior versions of .NET CLI
2017-04-19 04:12:35 +08:00
- Downloads and installs a preview version of .NET Core SDK 2.0 to `~/.dotnet`
2016-04-14 07:41:50 +08:00
2016-07-22 06:50:04 +08:00
If you want to use `dotnet` outside of `Start-PSBuild` ,
add `~/.dotnet` to your `PATH` environment variable.
2016-03-31 05:30:13 +08:00
2017-04-19 04:12:35 +08:00
### error: Too many open files
2016-04-15 02:25:09 +08:00
2016-07-22 06:50:04 +08: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-19 04:12:35 +08:00
add it to your shell's profile to fix it permanently.
2016-04-15 02:25:09 +08:00
2016-08-19 01:47:23 +08:00
We cannot do this for you in the build module due to #[847][].
2016-04-15 02:25:09 +08:00
[809]: https://github.com/dotnet/cli/issues/809
[847]: https://github.com/PowerShell/PowerShell/issues/847
2017-04-19 04:12:35 +08:00
## Build using our module
2016-03-31 05:30:13 +08:00
2016-07-22 06:50:04 +08:00
Instead of installing the Ubuntu package of PowerShell,
download the `pkg` from our GitHub releases page using your browser, complete the wizard,
start a `powershell` session, and use `Start-PSBuild` from the module.
2017-04-19 04:12:35 +08:00
After building, PowerShell will be at `./src/powershell-unix/bin/Linux/netcoreapp2.0/osx.10.12-x64/publish/powershell` .
2016-08-19 01:47:23 +08:00
Note that configuration is still `Linux` because it would be silly to make yet another separate configuration when it's used solely to work-around a CLI issue.