I'm making my first attempt at extending SIF, and I don't seem to be able to register a new Task correctly. Can anyone suggest what I'm doing wrong here?
I've create a new script commandlet. It has the following contents:
function Invoke-SolrInstallTask
{
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[parameter(Mandatory=$true)]
[string]$solrVersion = "6.6.2",
#
# more declarations
#
)
PROCESS
{
#
# Code for the task...
#
}
}
Export-ModuleMember -Function Invoke-SolrInstallTask
That file is saved as Invoke-SolrInstallTask.psm1
in my user's module folder at
C:\Users\<myUser>\Documents\WindowsPowerShell\Modules\Invoke-SolrInstallTask\
Calling
Import-Module Invoke-SolrInstallTask
appears to work, and a subsequent call to Get-Module
shows that PowerShell has registered my function as a script:
If I try to run my commandlet directly it appears to work ok. So then I call:
Register-SitecoreInstallExtension Invoke-SolrInstallTask -As SolrInstall -Type Task
That generates no output.
I can see from the SIF that documentation that Get-SitecoreInstallExtension
only returns references to standard tasks, unless you call it passing a configuration file.
My solr.json
config file contains (amongst other stuff) a block that tries to use the custom task:
"Tasks" : {
"PerformSolrInstall": {
"Type": "SolrInstall",
"Params": {
"solrVersion": "[parameter('SolrVersion')]"
}
}
}
But despite that Get-SitecoreInstallExtension .\solr.json
never returns any reference to my task:
And unsurprisingly, if I try to run that custom config I get an error:
I'm guessing there's some other bit of "how to register a custom task" that I've failed to find in the documentation. Any suggestions what it is?