2016-03-31 00:12:58 +02:00
|
|
|
Build PowerShell on Windows for .NET Full
|
|
|
|
=========================================
|
|
|
|
|
|
|
|
This guide supplements the
|
|
|
|
[Windows .NET Core instructions](./windows-core.md), as building the
|
2016-04-05 04:18:15 +02:00
|
|
|
.NET 4.5.1 (desktop) version is pretty similar.
|
2016-03-31 00:12:58 +02:00
|
|
|
|
|
|
|
Environment
|
|
|
|
===========
|
|
|
|
|
|
|
|
In addition to the dependencies specified in the .NET Core
|
|
|
|
instructions, we need:
|
|
|
|
|
|
|
|
Install the Visual C++ Compiler via Visual Studio 2015.
|
|
|
|
-------------------------------------------------------
|
|
|
|
|
|
|
|
This component is required to compile the native `powershell.exe` host.
|
|
|
|
|
|
|
|
This is an optionally installed component, so you may need to run the
|
|
|
|
Visual Studio installer again.
|
|
|
|
|
|
|
|
If you don't have any Visual Studio installed, you can use
|
|
|
|
[Visual Studio 2015 Community Edition][vs].
|
|
|
|
|
|
|
|
> Compiling with older versions should work, but we don't test it.
|
|
|
|
|
|
|
|
**Troubleshooting note:** If `cmake` says that it cannot determine the
|
|
|
|
`C` and `CXX` compilers, you either don't have Visual Studio, or you
|
|
|
|
don't have the Visual C++ Compiler component installed.
|
|
|
|
|
|
|
|
[vs]: https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx
|
|
|
|
|
|
|
|
Install CMake and add it to `PATH`.
|
|
|
|
-----------------------------------
|
|
|
|
|
|
|
|
You can install it from [Chocolatey][] or [manually][].
|
|
|
|
|
|
|
|
```
|
|
|
|
choco install cmake.portable
|
|
|
|
```
|
|
|
|
|
|
|
|
[Chocolatey]: https://chocolatey.org/packages/cmake.portable
|
|
|
|
[manually]: https://cmake.org/download/
|
|
|
|
|
|
|
|
Build using our module
|
|
|
|
======================
|
|
|
|
|
2016-05-18 22:58:59 +02:00
|
|
|
Use `Start-PSBuild -FullCLR` from the `build.psm1`
|
2016-04-05 04:18:15 +02:00
|
|
|
module.
|
|
|
|
|
|
|
|
Because the `ConsoleHost` project (*not* the `Host` project) is a
|
|
|
|
library and not an application (in the sense that .NET CLI does not
|
|
|
|
emit a native executable using .NET Core's `corehost`), it targets the
|
2016-07-01 22:51:14 +02:00
|
|
|
framework `netstandard1.6`, *not* `netcoreapp1.0`, and the build
|
2016-04-05 04:18:15 +02:00
|
|
|
output will *not* have a runtime identifier in the path.
|
|
|
|
|
|
|
|
Thus the output location of `powershell.exe` will be
|
2016-06-17 01:36:27 +02:00
|
|
|
`./src/Microsoft.PowerShell.ConsoleHost/bin/Debug/net451/powershell.exe`
|
2016-03-31 00:12:58 +02:00
|
|
|
|
|
|
|
While building is easy, running FullCLR version is not as simple as
|
|
|
|
CoreCLR version.
|
|
|
|
|
2016-04-05 04:18:15 +02:00
|
|
|
If you just run ~~`./powershell.exe`~~, you will get a `powershell`
|
|
|
|
process, but all the interesting DLLs (such as
|
|
|
|
`System.Management.Automation.dll`) would be loaded from the Global
|
|
|
|
Assembly Cache (GAC), not your output directory.
|
2016-03-31 00:12:58 +02:00
|
|
|
|
|
|
|
[@lzybkr](https://github.com/lzybkr) wrote a module to deal with it
|
|
|
|
and run side-by-side.
|
|
|
|
|
|
|
|
```powershell
|
2016-07-01 22:51:14 +02:00
|
|
|
Start-DevPowerShell
|
2016-04-05 04:54:12 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
This command has a reasonable default to run `powershell.exe` from the build output folder.
|
|
|
|
If you are building an unusual configuration (i.e. not `Debug`), you can explicitly specify path to the bin directory
|
|
|
|
|
|
|
|
```powershell
|
2016-07-01 22:51:14 +02:00
|
|
|
Start-DevPowerShell -binDir .\src\Microsoft.PowerShell.ConsoleHost\bin\Debug\net451
|
2016-04-05 04:18:15 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
Or more programmatically:
|
|
|
|
|
|
|
|
```powershell
|
2016-07-01 22:51:14 +02:00
|
|
|
Start-DevPowerShell -binDir (Split-Path -Parent (Get-PSOutput))
|
2016-03-31 00:12:58 +02:00
|
|
|
```
|
|
|
|
|
2016-07-01 22:51:14 +02:00
|
|
|
The default for produced `powershell.exe` is x64.
|
|
|
|
You can contorl it with `Start-PSBuild -FullCLR -NativeHostArch x86`
|
2016-03-31 00:12:58 +02:00
|
|
|
|
|
|
|
Build manually
|
|
|
|
==============
|
|
|
|
|
|
|
|
The build logic is relatively simple and contains the following steps:
|
|
|
|
|
|
|
|
- building managed DLLs: `dotnet publish --runtime net451`
|
2016-07-01 22:51:14 +02:00
|
|
|
- generating Visual Studio project: `cmake`
|
2016-03-31 00:12:58 +02:00
|
|
|
- building `powershell.exe` from generated solution: `msbuild
|
|
|
|
powershell.sln`
|
|
|
|
|
|
|
|
Please don't hesitate to experiment.
|