From 0ca44f147d659474a0591ebb51bcc7fca4dcb1f7 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 15 Aug 2017 16:17:45 -0700 Subject: [PATCH] Package only from the powershell folder at the root directory (#4569) --- build.psm1 | 18 +++++++++++++++++- tools/appveyor.psm1 | 2 +- tools/packaging/packaging.psm1 | 11 ++++++++++- tools/travis.ps1 | 5 +++-- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/build.psm1 b/build.psm1 index be3c257e8b..240ddf75a4 100644 --- a/build.psm1 +++ b/build.psm1 @@ -723,7 +723,23 @@ function New-PSOptions { $Top = [IO.Path]::Combine($PSScriptRoot, "src", "System.Management.Automation") } - return @{ Top = $Top; + $RootInfo = @{RepoPath = $PSScriptRoot} + + # the valid root is the root of the filesystem and the folder PowerShell + $RootInfo['ValidPath'] = Join-Path -Path ([system.io.path]::GetPathRoot($RootInfo.RepoPath)) -ChildPath 'PowerShell' + + if($RepoInfo.RepoPath -ne $RootInfo.ValidPath) + { + $RootInfo['Warning'] = "Please ensure you repo is at the root of the file system and named 'PowerShell' (example: '$($RootInfo.ValidPath)'), when building and packaging for release!" + $RootInfo['IsValid'] = $false + } + else + { + $RootInfo['IsValid'] = $true + } + + return @{ RootInfo = [PSCustomObject]$RootInfo + Top = $Top; Configuration = $Configuration; Framework = $Framework; Runtime = $Runtime; diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index a278922aeb..068577c085 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -448,7 +448,7 @@ function Invoke-AppveyorFinish } # Build packages - $packages = Start-PSPackage @packageParams + $packages = Start-PSPackage @packageParams -SkipReleaseChecks $name = Get-PackageName diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 88f83ed221..026a353523 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -29,7 +29,9 @@ function Start-PSPackage { [Switch] $Force, - [Switch] $IncludeSymbols + [Switch] $IncludeSymbols, + + [Switch] $SkipReleaseChecks ) # Runtime and Configuration settings required by the package @@ -81,6 +83,13 @@ function Start-PSPackage { throw "Please ensure you have run 'Start-PSBuild $params'!" } + if($SkipReleaseChecks.IsPresent) { + Write-Warning "Skipping release checks." + } + elseif(!$Script:Options.RootInfo.IsValid){ + throw $Script:Options.RootInfo.Warning + } + # If ReleaseTag is specified, use the given tag to calculate Vesrion if ($PSCmdlet.ParameterSetName -eq "ReleaseTag") { $Version = $ReleaseTag -Replace '^v' diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 58a8aad1ef..4b681dc69e 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -179,8 +179,9 @@ else $packageParams += @{Version=$version} } # Only build packages for branches, not pull requests - $packages = @(Start-PSPackage @packageParams) - $packages += Start-PSPackage @packageParams -Type AppImage + $packages = @(Start-PSPackage @packageParams -SkipReleaseChecks) + # Packaging AppImage depends on the deb package + $packages += Start-PSPackage @packageParams -Type AppImage -SkipReleaseChecks foreach($package in $packages) { # Publish the packages to the nuget feed if: