diff --git a/build.psm1 b/build.psm1 index e546506d4d..dc356337c5 100644 --- a/build.psm1 +++ b/build.psm1 @@ -30,6 +30,10 @@ if ($IsLinux) { function Start-PSBuild { [CmdletBinding(DefaultParameterSetName='CoreCLR')] param( + # When specified this switch will stops running dev powershell + # to help avoid compilation error, because file are in use. + [switch]$StopDevPowerShell, + [switch]$NoPath, [switch]$Restore, [string]$Output, @@ -37,6 +41,10 @@ function Start-PSBuild { [switch]$TypeGen, [switch]$Clean, + # this switch will re-build only System.Mangement.Automation.dll + # it's useful for development, to do a quick changes in the engine + [switch]$SMAOnly, + [Parameter(ParameterSetName='CoreCLR')] [switch]$Publish, @@ -66,6 +74,18 @@ function Start-PSBuild { [string]$Configuration ) + function Stop-DevPowerShell + { + Get-Process powershell* | + Where-Object { + $_.Modules | + Where-Object { + $_.FileName -eq (Resolve-Path $script:Options.Output).Path + } + } | + Stop-Process -Verbose + } + if ($Clean) { log "Cleaning your working directory. You can also do it with 'git clean -fdX'" @@ -142,9 +162,22 @@ function Start-PSBuild { } # set output options - $OptionsArguments = @{Publish=$Publish; Output=$Output; FullCLR=$FullCLR; Runtime=$Runtime; Configuration=$Configuration; Verbose=$true} + $OptionsArguments = @{ + Publish=$Publish + Output=$Output + FullCLR=$FullCLR + Runtime=$Runtime + Configuration=$Configuration + Verbose=$true + SMAOnly=[bool]$SMAOnly + } $script:Options = New-PSOptions @OptionsArguments + if ($StopDevPowerShell) + { + Stop-DevPowerShell + } + # setup arguments $Arguments = @() if ($Publish) { @@ -155,6 +188,10 @@ function Start-PSBuild { if ($Output) { $Arguments += "--output", (Join-Path $PSScriptRoot $Output) } + elseif ($SMAOnly) { + $Arguments += "--output", (Split-Path $script:Options.Output) + } + $Arguments += "--configuration", $Options.Configuration $Arguments += "--framework", $Options.Framework $Arguments += "--runtime", $Options.Runtime @@ -215,7 +252,7 @@ function Start-PSBuild { if (-not (Test-Path $Lib)) { throw "Compilation of $Lib failed" } - } elseif ($FullCLR) { + } elseif ($FullCLR -and (-not $SMAOnly)) { log "Start building native powershell.exe" try { @@ -277,7 +314,6 @@ cmd.exe /C cd /d "$location" "&" "$($vcVarsPath)\vcvarsall.bat" "$NativeHostArch } } - function New-PSOptions { [CmdletBinding()] param( @@ -302,7 +338,9 @@ function New-PSOptions { [switch]$Publish, [string]$Output, - [switch]$FullCLR + [switch]$FullCLR, + + [switch]$SMAOnly ) # Add .NET CLI tools to PATH @@ -372,9 +410,19 @@ function New-PSOptions { $Output = [IO.Path]::Combine($Output, $Executable) } + $RealFramework = $Framework + if ($SMAOnly) + { + $Top = "$PSScriptRoot/src/System.Management.Automation" + if ($Framework -match 'netcoreapp') + { + $RealFramework = 'netstandard1.6' + } + } + return @{ Top = $Top; Configuration = $Configuration; - Framework = $Framework; + Framework = $RealFramework; Runtime = $Runtime; Output = $Output } } @@ -721,7 +769,6 @@ function Publish-NuGetFeed } } - function Start-DevPowerShell { param( [switch]$ZapDisable,