Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Requirement Rules Script Files not processed during Prepare-AppPackageFolder #13

Open
PZan opened this issue Dec 11, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@PZan
Copy link

PZan commented Dec 11, 2023

I realize the documentation states that the section "CustomRequirementRule" will be further documented in the future, but I went ahead and defined the required variables in a app.json file as this was desired in my particular case for Dell Command | Update. (My custom requrement rule variables and values where based off of the expected variables in the switch statement starting on line 350 of New-Win32App.ps1)

When New-Win32App.ps1 is running and has app.json has custom requirement rule script files defined, the pipeline will fail because the script file is missing in the Scripts folder. After investigating this my conclusion is that the Prepare-AppPackageFolder.ps1 should process each custom requirement rule with script files while processing "app.json" (line 110) in the switch statement.

Adding the following to line 110 in Prepare-AppPackageFolder.ps1 did the trick for me:

# Copy custom requirement rule script files to script destination folder
foreach ( $CustomRequirementRuleScript in $($AppFileContent.CustomRequirementRule | Where-Object {$_.Type -eq "Script" } ) ) {
    # Create the Scripts folder in the app package folder in the publish root folder
    $AppPublishScriptsFolderPath = Join-Path -Path $AppPublishFolderPath -ChildPath "Scripts"

    $ScriptFileSource = Join-Path $AppPackageFolderPath -ChildPath $CustomRequirementRuleScript.ScriptFile
    $ScriptFileDestination = Join-Path -Path $AppPublishScriptsFolderPath -ChildPath $CustomRequirementRuleScript.ScriptFile

    if (-not(Test-Path -Path $AppPublishScriptsFolderPath)) {
        try {
            $null = New-Item -Path $AppPublishScriptsFolderPath -ItemType "Directory" -Force -Confirm:$false   
        }
        catch [System.Exception] {
            Write-Warning "Failed to create folder [$AppPublishFolderPath] with message: [$($_.Exception.Message)]"
        }
    }

    try {
        Write-Output "Copying custom requirement rule script file from: [$ScriptFileSource] to: [$ScriptFileDestination]"
        $null = Copy-Item -Path $ScriptFileSource -Destination $ScriptFileDestination -Force -ErrorAction Stop
    }
    catch [System.Exception] {
        Write-Warning "Failed to copy custom requirement rule script with message: [$($_.Exception.Message)]"
    }
}
@NickolajA NickolajA self-assigned this Aug 25, 2024
@NickolajA NickolajA added the enhancement New feature or request label Aug 25, 2024
@NickolajA
Copy link
Member

Makes total sense. It's been on the to do list to complete this part, so thanks for sharing your code! Will add it to 1.2.0 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants