From 3f1ba7a60545f2289244bdef61e321f1d54d6863 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Tue, 19 Jul 2016 12:51:11 -0700 Subject: [PATCH 1/2] Add Start-PSBuild -SMAOnly option for faster incremental builds --- build.psm1 | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/build.psm1 b/build.psm1 index 95ee565a81..3b42c1c9cb 100644 --- a/build.psm1 +++ b/build.psm1 @@ -37,6 +37,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, @@ -138,7 +142,15 @@ 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 # setup arguments @@ -151,6 +163,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 @@ -211,7 +227,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 { @@ -282,7 +298,9 @@ function New-PSOptions { [switch]$Publish, [string]$Output, - [switch]$FullCLR + [switch]$FullCLR, + + [switch]$SMAOnly ) # Add .NET CLI tools to PATH @@ -352,9 +370,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 } } From 738d4ea0059baea20470a6e8f03ebecd7f37a1b8 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Tue, 19 Jul 2016 19:09:06 -0700 Subject: [PATCH 2/2] Add Start-PSBuild -StopDevPowerShell switch --- build.psm1 | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/build.psm1 b/build.psm1 index 3b42c1c9cb..899e91b763 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, @@ -70,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'" @@ -153,6 +169,11 @@ function Start-PSBuild { } $script:Options = New-PSOptions @OptionsArguments + if ($StopDevPowerShell) + { + Stop-DevPowerShell + } + # setup arguments $Arguments = @() if ($Publish) { @@ -273,7 +294,6 @@ function Start-PSBuild { } - function New-PSOptions { [CmdletBinding()] param( @@ -729,7 +749,6 @@ function Publish-NuGetFeed } } - function Start-DevPowerShell { param( [switch]$ZapDisable,