Add instrumentation for Start-PSPackage (#8811)

Add instrumentation for start-PSPackage saying what parameters it thinks you used
This commit is contained in:
Travis Plunk
2019-02-04 11:48:48 -08:00
committed by GitHub
parent fce6a97b78
commit 6b447423a0
+12
View File
@@ -93,6 +93,7 @@ function Start-PSPackage {
}
$Script:Options = Get-PSOptions
$actualParams = @()
$crossGenCorrect = $false
if ($Runtime -match "arm") {
@@ -100,6 +101,7 @@ function Start-PSPackage {
$crossGenCorrect = $true
}
elseif ($Script:Options.CrossGen) {
$actualParams += '-CrossGen'
$crossGenCorrect = $true
}
@@ -108,11 +110,15 @@ function Start-PSPackage {
# Require PSModuleRestore for packaging without symbols
# But Disallow it when packaging with symbols
if (!$IncludeSymbols.IsPresent -and $Script:Options.PSModuleRestore) {
$actualParams += '-PSModuleRestore'
$PSModuleRestoreCorrect = $true
}
elseif ($IncludeSymbols.IsPresent -and !$Script:Options.PSModuleRestore) {
$PSModuleRestoreCorrect = $true
}
else {
$actualParams += '-PSModuleRestore'
}
$precheckFailed = if ($Type -eq 'fxdependent' -or $Type -eq 'tar-alpine') {
## We do not check for runtime and crossgen for framework dependent package.
@@ -141,6 +147,8 @@ function Start-PSPackage {
# This check serves as a simple gate to ensure that the user knows what he is doing, and
# also ensure `Start-PSPackage` does what the user asks/expects, because once packages
# are generated, it'll be hard to verify if they were built from the correct content.
$params = @('-Clean')
# CrossGen cannot be done for framework dependent package as it is runtime agnostic.
@@ -152,6 +160,8 @@ function Start-PSPackage {
$params += '-PSModuleRestore'
}
$actualParams += '-Runtime ' + $Script:Options.Runtime
if ($Type -eq 'fxdependent') {
$params += '-Runtime', 'fxdependent'
} else {
@@ -159,7 +169,9 @@ function Start-PSPackage {
}
$params += '-Configuration', $Configuration
$actualParams += '-Configuration ' + $Script:Options.Configuration
Write-Warning "Build started with unexpected parameters 'Start-PSBuild $actualParams"
throw "Please ensure you have run 'Start-PSBuild $params'!"
}