Skip to content

Instantly share code, notes, and snippets.

@gerane
Last active May 21, 2016 13:07
Show Gist options
  • Save gerane/8272e87708fe48968b5e00372d58e8a1 to your computer and use it in GitHub Desktop.
Save gerane/8272e87708fe48968b5e00372d58e8a1 to your computer and use it in GitHub Desktop.

Getting Started

  • Get the Plaster Module from Plaster Github
  • Get the latest version of the VS Code Powershell Extension.
  • Create a zip file of the contents of the NewModuleTemplate folder in the Examples.
  • Set the TemplatePath variable in the ps1 file below to the path of the zip.
  • Set a Destination directory in the ps1 below.
  • Either place the code below in the Microsoft.VSCode_profile.ps1 profile or highlight and hit f8 to temporarily load it for testing.
  • Start the Command Palette by pressing f1 or ctrl+shift+P
  • type 'addi' and hit enter (Short for Show additional commands for powershell modules)
  • Enter the information prompted.

Addional Information

  • This was just a quick demo. You will want to customize this to fit your needs.
  • Plaster as has special variables that it will convert when creating your scaffolding.
  • In the example, all of the names, module name, dates, etc were all filled in by Plaster.
  • Here is an example of the variables in use from the Example Module
$ModuleManifestName = '<%=$PLASTER_PARAM_ModuleName%>.psd1'
# <%=${PLASTER_GUID1}%> - testing use of PLASTER predefined variables.
Import-Module $PSScriptRoot\..\$ModuleManifestName

Describe 'Module Manifest Tests' {
    It 'Passes Test-ModuleManifest' {
        Test-ModuleManifest -Path $PSScriptRoot\..\$ModuleManifestName
        $? | Should Be $true
    }
}
  • After the Module is created it turns into this
$ModuleManifestName = 'testmodule.psd1'
# 80f8c343-8c29-4086-99f6-06d5e7f74968 - testing use of PLASTER predefined variables.
Import-Module $PSScriptRoot\..\$ModuleManifestName

Describe 'Module Manifest Tests' {
    It 'Passes Test-ModuleManifest' {
        Test-ModuleManifest -Path $PSScriptRoot\..\$ModuleManifestName
        $? | Should Be $true
    }
}
  • You could set defaults for more of these options such as
    • Fullname = Your Name
    • Version - 1.0.0
    • License = License you prefer
    • Options = 0,1,2 or which you prefer
  • You can basically narrow it down to everything but the name if that is what works best for you
  • Plaster is extensible and can be used to create any kind of project scaffolding.
  • My first usage was to create a template for PSAppDeployToolkit that have been customized to my needs.
Register-EditorCommand `
-Name "PlasterToolkit.InvokePlasterModule" `
-DisplayName "Create New Module" `
-ScriptBlock {
param([Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context)
$TemplatePath = "$(Get-OneDriveDir)\PowerShell\Plaster\ModuleTemplate.zip"
$Destination = "C:\Test"
Invoke-Plaster -TemplatePath $TemplatePath -DestinationPath $Destination
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment