Data/Example-ModuleBuilder.txt

Build-Module -ModuleName '$ModuleName' {
    # Usual defaults as per standard module
    $Manifest = [ordered] @{
        ModuleVersion = '1.0.0'
        CompatiblePSEditions = @('Desktop', 'Core')
        GUID = '$Guid'
        Author = 'Author'
        CompanyName = 'CompanyName'
        Copyright = "(c) 2011 - $((Get-Date).Year) Author @ CompanyName. All rights reserved."
        Description = 'Simple project $ModuleName'
        PowerShellVersion = '5.1'
        Tags = @('Windows', 'MacOS', 'Linux')
    }
    New-ConfigurationManifest @Manifest
 
    # Add standard module dependencies (directly, but can be used with loop as well)
    #New-ConfigurationModule -Type RequiredModule -Name 'PSSharedGoods' -Guid 'Auto' -Version 'Latest'
 
    # Add external module dependencies, using loop for simplicity
    #foreach ($Module in @('Microsoft.PowerShell.Utility', 'Microsoft.PowerShell.Archive', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Security')) {
    # New-ConfigurationModule -Type ExternalModule -Name $Module
    #}
 
    # Add approved modules, that can be used as a dependency, but only when specific function from those modules is used
    # And on that time only that function and dependant functions will be copied over
    # Keep in mind it has it's limits when "copying" functions such as it should not depend on DLLs or other external files
    #New-ConfigurationModule -Type ApprovedModule -Name 'PSSharedGoods', 'PSWriteColor', 'Connectimo', 'PSUnifi', 'PSWebToolbox', 'PSMyPassword'
 
    #New-ConfigurationModuleSkip -IgnoreFunctionName 'Invoke-Formatter', 'Find-Module' -IgnoreModuleName 'platyPS'
 
    $ConfigurationFormat = [ordered] @{
        RemoveComments = $false
 
        PlaceOpenBraceEnable = $true
        PlaceOpenBraceOnSameLine = $true
        PlaceOpenBraceNewLineAfter = $true
        PlaceOpenBraceIgnoreOneLineBlock = $false
 
        PlaceCloseBraceEnable = $true
        PlaceCloseBraceNewLineAfter = $true
        PlaceCloseBraceIgnoreOneLineBlock = $false
        PlaceCloseBraceNoEmptyLineBefore = $true
 
        UseConsistentIndentationEnable = $true
        UseConsistentIndentationKind = 'space'
        UseConsistentIndentationPipelineIndentation = 'IncreaseIndentationAfterEveryPipeline'
        UseConsistentIndentationIndentationSize = 4
 
        UseConsistentWhitespaceEnable = $true
        UseConsistentWhitespaceCheckInnerBrace = $true
        UseConsistentWhitespaceCheckOpenBrace = $true
        UseConsistentWhitespaceCheckOpenParen = $true
        UseConsistentWhitespaceCheckOperator = $true
        UseConsistentWhitespaceCheckPipe = $true
        UseConsistentWhitespaceCheckSeparator = $true
 
        AlignAssignmentStatementEnable = $true
        AlignAssignmentStatementCheckHashtable = $true
 
        UseCorrectCasingEnable = $true
    }
    # format PSD1 and PSM1 files when merging into a single file
    # enable formatting is not required as Configuration is provided
    New-ConfigurationFormat -ApplyTo 'OnMergePSM1', 'OnMergePSD1' -Sort None @ConfigurationFormat
    # format PSD1 and PSM1 files within the module
    # enable formatting is required to make sure that formatting is applied (with default settings)
    New-ConfigurationFormat -ApplyTo 'DefaultPSD1', 'DefaultPSM1' -EnableFormatting -Sort None
    # when creating PSD1 use special style without comments and with only required parameters
    New-ConfigurationFormat -ApplyTo 'DefaultPSD1', 'OnMergePSD1' -PSD1Style 'Minimal'
 
    # configuration for documentation, at the same time it enables documentation processing
    New-ConfigurationDocumentation -Enable:$false -StartClean -UpdateWhenNew -PathReadme 'Docs\Readme.md' -Path 'Docs'
 
    New-ConfigurationImportModule -ImportSelf -ImportRequiredModules
 
    New-ConfigurationBuild -Enable:$true -SignModule:$false -DeleteTargetModuleBeforeBuild -MergeModuleOnBuild
 
    #New-ConfigurationArtefact -Type Unpacked -Enable -Path "$PSScriptRoot\..\Artefacts" -RequiredModulesPath "$PSScriptRoot\..\Artefacts\Modules"
    #New-ConfigurationArtefact -Type Packed -Enable -Path "$PSScriptRoot\..\Releases" -IncludeTagName
 
    # global options for publishing to github/psgallery
    #New-ConfigurationPublish -Type PowerShellGallery -FilePath 'C:\Support\Important\PowerShellGalleryAPI.txt' -Enabled:$false
    #New-ConfigurationPublish -Type GitHub -FilePath 'C:\Support\Important\GitHubAPI.txt' -UserName 'CompanyName' -Enabled:$false
}