{"action":"created","issue":{"url":"https://api.github.com/repos/nightroman/Invoke-Build/issues/28","repository_url":"https://api.github.com/repos/nightroman/Invoke-Build","labels_url":"https://api.github.com/repos/nightroman/Invoke-Build/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/nightroman/Invoke-Build/issues/28/comments","events_url":"https://api.github.com/repos/nightroman/Invoke-Build/issues/28/events","html_url":"https://github.com/nightroman/Invoke-Build/issues/28","id":164730819,"number":28,"title":"Conditional Task Issue?","user":{"login":"zloeber","id":4702624,"avatar_url":"https://avatars.githubusercontent.com/u/4702624?v=3","gravatar_id":"","url":"https://api.github.com/users/zloeber","html_url":"https://github.com/zloeber","followers_url":"https://api.github.com/users/zloeber/followers","following_url":"https://api.github.com/users/zloeber/following{/other_user}","gists_url":"https://api.github.com/users/zloeber/gists{/gist_id}","starred_url":"https://api.github.com/users/zloeber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zloeber/subscriptions","organizations_url":"https://api.github.com/users/zloeber/orgs","repos_url":"https://api.github.com/users/zloeber/repos","events_url":"https://api.github.com/users/zloeber/events{/privacy}","received_events_url":"https://api.github.com/users/zloeber/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-10T19:48:24Z","updated_at":"2016-07-11T05:36:25Z","closed_at":null,"body":"I'm not certain if I'm possibly just missing something or what but I cannot get conditional tasks to work. Here is an extremely simple example.\r\n\r\n```\r\n#Synopsis: Validate script requirements are met, load required modules, and load build tools.\r\ntask Configure {\r\n    # If we made it this far then we are configured!\r\n    $Script:IsConfigured = $True\r\n        Write-Host 'configured!'\r\n}, TestConfigure\r\n\r\ntask TestConfigure -If ($Script:IsConfigured -eq $true) {\r\n    Write-Host 'configured...for certain!'\r\n}\r\n```\r\n\r\nIf I run invoke-build Configure it will always skip the TestConfigure task."},"comment":{"url":"https://api.github.com/repos/nightroman/Invoke-Build/issues/comments/231646082","html_url":"https://github.com/nightroman/Invoke-Build/issues/28#issuecomment-231646082","issue_url":"https://api.github.com/repos/nightroman/Invoke-Build/issues/28","id":231646082,"user":{"login":"nightroman","id":927533,"avatar_url":"https://avatars.githubusercontent.com/u/927533?v=3","gravatar_id":"","url":"https://api.github.com/users/nightroman","html_url":"https://github.com/nightroman","followers_url":"https://api.github.com/users/nightroman/followers","following_url":"https://api.github.com/users/nightroman/following{/other_user}","gists_url":"https://api.github.com/users/nightroman/gists{/gist_id}","starred_url":"https://api.github.com/users/nightroman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nightroman/subscriptions","organizations_url":"https://api.github.com/users/nightroman/orgs","repos_url":"https://api.github.com/users/nightroman/repos","events_url":"https://api.github.com/users/nightroman/events{/privacy}","received_events_url":"https://api.github.com/users/nightroman/received_events","type":"User","site_admin":false},"created_at":"2016-07-11T05:36:25Z","updated_at":"2016-07-11T05:36:25Z","body":"\r\nTask parameters `If`, `Inputs`, and `Outputs` can be either script blocks\r\nevaluated on task invocation or other values evaluated on task definition.\r\n\r\nIn your case the value for `If` may change after adding tasks and you want to\r\nuse the current changed value on invocation of the task `TestConfigure`. So use\r\nthe script block:\r\n\r\n    task TestConfigure -If {$Script:IsConfigured} {\r\n        Write-Host 'configured...for certain!'\r\n    }\r\n\r\nYou should use `-If $Script:IsConfigured` only if `$Script:IsConfigured` does\r\nnot change or you specifically want to check for the original value, not\r\nchanged during the build.\r\n\r\n----\r\n\r\nIf values for `If` (or `Inputs`, `Outputs`) do not change during the build then\r\nit does not matter what to use, `-If {}` or `-If ()`. But if the expression is\r\ncomplex/expensive you may choose `-If {}` in order to avoid evaluation if a\r\ntask is not invoked at all in the build. On the other hand, if you want to\r\ncatch potential problems earlier, at a task definition, then you still may\r\nwant to use `-If ()`.\r\n\r\nShould we improve help perhaps? Here is the current:\r\n\r\n    0> . Invoke-Build\r\n    0> help task -Parameter If\r\n\r\n    -If\r\n        Specifies the optional condition to be evaluated. If the condition\r\n        evaluates to false then the task is not invoked.\r\n\r\n        The value is a script block evaluated on task invocation or an object\r\n        treated as Boolean on definition. On WhatIf a script block is treated\r\n        as true without invocation.\r\n\r\n        If the task is called several times then it is possible that the task\r\n        is skipped at first but invoked later when the script block gets true.\r\n"}}
{"actor":{"display_login":"nightroman"}}