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

Add dynamic validateset to tasklist in bootstrapper file #14

Open
motowilliams opened this issue Dec 2, 2016 · 0 comments
Open

Add dynamic validateset to tasklist in bootstrapper file #14

motowilliams opened this issue Dec 2, 2016 · 0 comments

Comments

@motowilliams
Copy link
Collaborator

Something like

$psakeBootstrap = ".\run.ps1"
$buildscript = ".\default.ps1"

function Set-Tasks() {
    $tasks = (Select-String -Path $buildscript -Pattern "task \w+(\-)?\w+").matches | ForEach-Object { $_.Value.Split(" ")[1] } | Sort-Object
    $taskListString = [string]::Join("','",$tasks)
    $content = get-content $psakeBootstrap | ForEach-Object { $_ -replace "\[ValidateSet.*\]", "[ValidateSet('$taskListString')]" }
    $content | Out-File -FilePath $psakeBootstrap -Encoding ascii
}

Export-ModuleMember -Function Set-Tasks

and in 'run.ps1'

Remove-Module [S]et-Tasks
Import-Module ".\Set-Tasks.psm1"
Set-Tasks

which will just overwrite the [ValidateSet( line on itself

super hacky but just an idea

Using Psake's built-in Get-PSakeScriptTasks | Select-Object { $_.name } is probably a better idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant