From 738d4ea0059baea20470a6e8f03ebecd7f37a1b8 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Tue, 19 Jul 2016 19:09:06 -0700 Subject: [PATCH] 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,