Packaging templates

If you want to package templates alongside your modules, or in a specific module, so that they can be discovered automatically, you just need to reference the relative template path in your module manifest's PrivateData table in the key PSData. At the time of writing, there is an ongoing discussion at https://github.com/PowerShell/Plaster/issues/224 regarding the dangers of packaging these templates alongside modules.

Since, for the time being, there is no other delivery vehicle for templates, you can use this mechanism and publish modules containing your templates to your internal gallery, for example:

# Automatic discovery
# Your module manifest needs to contain an Extensions key in
# the PSData hashtable
$excerpt = @{
Extensions = @(
@{
Module = "Plaster"
MinimumVersion = "0.3.0"
Details = @{
TemplatePaths = @("TemplatesFirstTemplate", "TemplatesSecondTemplate")
}
}
)
}

# That given, you can use these templates as well. They also appear in VSCode
$destination = Join-Path -Path ([IO.Path]::GetTempPath()) -ChildPath AutoDiscovered
$templates = Get-PlasterTemplate -IncludeInstalledModules
Invoke-Plaster -TemplatePath $templates[-1].TemplatePath -DestinationPath $destination

After adding your custom templates to one or more modules with the appropriate module manifest entry, VSCode can automatically discover those templates for you. Any template that is retrieved with Get-PlasterTemplate -IncludeInstalledModules will be listed here, alongside the built-in templates AddPSScriptAnalyzerSettings and New PowerShell Manifest Module:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.59.231