microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
381 stars 243 forks source link

Error when using validateNextMinor/NextMajor/Current in combination #3577

Open PaulFurlet opened 3 months ago

PaulFurlet commented 3 months ago

Describe the issue When I try to use Run-AlValidation with combination of -validateCurrent, -validateNextMinor and -validateNextMajor parameters, I get an error

Run-AlValidation : Cannot process argument transformation on parameter 'credential'. userName

Scripts used to create container and cause the issue

param (
    [String[]]$validationRequiredFor = ("dk"),
    [String]$validationRequiredWith = "NextMajor",
    [String]$appFileName = "c:\Development\app_1.0.0.1.app",
    [String]$oldAppFileName = "c:\Development\app_1.0.0.0.app"
)

Import-Module BCContainerHelper

$ValidateCurrent = $true
$ValidateMajor = $false
$ValidateMinor = $false
if ($validationRequiredFor -ne $null) {
    if ($validationRequiredWith -ne $null) {
        if ($validationRequiredWith -contains "NextMajor") {
            $ValidateCurrent = $false
            $ValidateMajor = $true
        }
        if ($validationRequiredWith -contains "NextMinor") {
            $ValidateCurrent = $false
            $ValidateMinor = $true
        }
        if ($validationRequiredWith -contains "Current") {
            $ValidateCurrent = $true
        }            
    }
    Run-AlValidation `
        -apps $appFileName `
        -previousApps  $oldAppFileName `
        -affixes "CUST" `
        -countries $validationRequiredFor `
        -validateCurrent $ValidateCurrent `
        -validateNextMinor $ValidateMinor `
        -validateNextMajor $ValidateMajor `
        -failOnError true
}

Full output of scripts

PS C:\Development> .\validate.ps1 -validationRequiredFor ("dk") -validationRequiredWith "NextMajor" -appFileName "c:\Development\app_1.0.0.1.app" -oldAppFileName "c:\Development\app_1.0.0.0.app"
BcContainerHelper version 6.0.18
BC.HelperFunctions emits usage statistics telemetry to Microsoft
Running on Windows, PowerShell 5.1.20348.2400
WARNING: The names of some imported commands from the module 'BCContainerHelper' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-
Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
Run-AlValidation : Cannot process argument transformation on parameter 'credential'. userName
At C:\Development\validate.ps1:34 char:28
+         -validateNextMajor $ValidateMajor `
+                            ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Run-AlValidation], ParameterBindingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Run-AlValidation

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

freddydk commented 2 months ago

ValidateCurrent, ValidateNextMinor, ValidateNextMajor and failOnError are switch parameters (not boolean) According to PowerShell syntax, you need to add a colon (and remove the true):

    Run-AlValidation `
        -apps $appFileName `
        -previousApps  $oldAppFileName `
        -affixes "CUST" `
        -countries $validationRequiredFor `
        -validateCurrent:$ValidateCurrent `
        -validateNextMinor:$ValidateMinor `
        -validateNextMajor:$ValidateMajor `
        -failOnError
PaulFurlet commented 2 months ago

Thanks for the answer. So if just in case of necessity, we cannot validate against all versions in one run, have to make three separate calls.

freddydk commented 2 months ago

No, you can run all 3 - you just had a powershell syntax error in your command.

PaulFurlet commented 2 months ago

Thanks!