RamblingCookieMonster / BuildHelpers

Helper functions for PowerShell CI/CD scenarios
MIT License
216 stars 47 forks source link

Allow setting of custom build variables #142

Open fourpastmidnight opened 1 year ago

fourpastmidnight commented 1 year ago

This pull request allows one to specify custom build variables that should be created when setting up the build environment when invoking Set-BuildEnvironment. Just like for the -BuildOutput parameter, it allows for the values of custom variables to contain the names of other custom variables and BuildHelpers-defined variables defined by the current call, which will be expanded.

For example, assuming my project is located in C:\Projects\MyProject:

Set-BuildEnvironment `
    -VariableNamePrefix 'MYPROJECT_' `
    -BuildOutput '$ProjectPath\build' `
    -CustomVariables @{
        'ARTIFACTSDIR' = '$ProjectPath\out'
        'HELPARTIFACTSDIR' = '$ARTIFACTSDIR\docs'
    } `

This would result in the following output for the custom variables:

Name                        Value
----                        -----
MYPROJECT_ARTIFACTSDIR      C:\Projects\MyProject\out
MYPROJECT_HELPARTIFACTSDIR  C:\Projects\MyProject\out\docs

Closes #141