Project

PSPublishModule

Build, test, version, sign, and publish PowerShell modules with reusable PowerForge pipelines.

Stars 48
Forks 16
PowerShell Gallery downloads 17,213
Release v3.0.169
Language: C# Updated: 2026-10-17
Command

New-ConfigurationFormat

Module PSPublishModule
Inputs
None

Builds formatting options for code and manifest generation during the build.

Syntax

New-ConfigurationFormat [-AlignAssignmentStatementCheckHashtable] [-AlignAssignmentStatementEnable] -ApplyTo <OnMergePSM1|OnMergePSD1|DefaultPS1|DefaultPSM1|DefaultPSD1> [-EnableFormatting] [-PlaceCloseBraceEnable] [-PlaceCloseBraceIgnoreOneLineBlock] [-PlaceCloseBraceNewLineAfter] [-PlaceCloseBraceNoEmptyLineBefore] [-PlaceOpenBraceEnable] [-PlaceOpenBraceIgnoreOneLineBlock] [-PlaceOpenBraceNewLineAfter] [-PlaceOpenBraceOnSameLine] [-PSD1Style <Minimal|Native>] [-RemoveAllEmptyLines] [-RemoveComments] [-RemoveCommentsBeforeParamBlock] [-RemoveCommentsInParamBlock] [-RemoveEmptyLines] [-Sort <Asc|Desc>] [-UpdateProjectRoot] [-UseConsistentIndentationEnable] [-UseConsistentIndentationIndentationSize <Int32>] [-UseConsistentIndentationKind <space|tab>] [-UseConsistentIndentationPipelineIndentation <IncreaseIndentationAfterEveryPipeline|NoIndentation>] [-UseConsistentWhitespaceCheckInnerBrace] [-UseConsistentWhitespaceCheckOpenBrace] [-UseConsistentWhitespaceCheckOpenParen] [-UseConsistentWhitespaceCheckOperator] [-UseConsistentWhitespaceCheckPipe] [-UseConsistentWhitespaceCheckSeparator] [-UseConsistentWhitespaceEnable] [-UseCorrectCasingEnable] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Produces a formatting configuration segment used by the build pipeline to normalize generated output (merged PSM1/PSD1) and optionally apply formatting back to the project root.

Examples

Authored help example

Remove comments and normalize whitespace during merge

New-ConfigurationFormat -ApplyTo OnMergePSM1,OnMergePSD1 -RemoveComments -RemoveEmptyLines

Formats the merged module output and removes comments while keeping readability.

Also update files in the project root

New-ConfigurationFormat -ApplyTo DefaultPSM1,DefaultPSD1 -EnableFormatting -UpdateProjectRoot

Applies formatting rules to the project sources as well as generated output.

Parameters

-AlignAssignmentStatementCheckHashtable SwitchParameter optional
For PSAlignAssignmentStatement: align hashtable assignments.
-AlignAssignmentStatementEnable SwitchParameter optional
Enable PSAlignAssignmentStatement rule and optionally check hashtable alignment.
-ApplyTo String[] required
Targets to apply formatting to (OnMergePSM1, OnMergePSD1, DefaultPS1, DefaultPSM1, DefaultPSD1).
Possible values: OnMergePSM1, OnMergePSD1, DefaultPS1, DefaultPSM1, DefaultPSD1
-EnableFormatting SwitchParameter optional
Enables formatting for the chosen ApplyTo targets even if no specific rule switches are provided.
-PlaceCloseBraceEnable SwitchParameter optional
Enable PSPlaceCloseBrace rule and configure its behavior.
-PlaceCloseBraceIgnoreOneLineBlock SwitchParameter optional
For PSPlaceCloseBrace: ignore single-line blocks.
-PlaceCloseBraceNewLineAfter SwitchParameter optional
For PSPlaceCloseBrace: enforce a new line after the closing brace.
-PlaceCloseBraceNoEmptyLineBefore SwitchParameter optional
For PSPlaceCloseBrace: do not allow an empty line before a closing brace.
-PlaceOpenBraceEnable SwitchParameter optional
Enable PSPlaceOpenBrace rule and configure its behavior.
-PlaceOpenBraceIgnoreOneLineBlock SwitchParameter optional
For PSPlaceOpenBrace: ignore single-line blocks.
-PlaceOpenBraceNewLineAfter SwitchParameter optional
For PSPlaceOpenBrace: enforce a new line after the opening brace.
-PlaceOpenBraceOnSameLine SwitchParameter optional
For PSPlaceOpenBrace: place opening brace on the same line.
-PSD1Style String optional
Style for generated manifests (PSD1) for the selected ApplyTo targets.
Possible values: Minimal, Native
-RemoveAllEmptyLines SwitchParameter optional
Remove all empty lines (more aggressive than RemoveEmptyLines).
-RemoveComments SwitchParameter optional
Remove comments in the formatted output.
-RemoveCommentsBeforeParamBlock SwitchParameter optional
Remove comments that appear immediately before the param() block.
-RemoveCommentsInParamBlock SwitchParameter optional
Remove comments within the param() block.
-RemoveEmptyLines SwitchParameter optional
Remove empty lines while preserving readability.
-Sort String optional
Optional ordering hint for internal processing. Accepts None, Asc, or Desc.
Possible values: Asc, Desc
-UpdateProjectRoot SwitchParameter optional
When set, formats PowerShell sources in the project root in addition to staging output.
-UseConsistentIndentationEnable SwitchParameter optional
Enable PSUseConsistentIndentation rule and configure its behavior.
-UseConsistentIndentationIndentationSize Int32 optional
Number of spaces for indentation when Kind is space.
-UseConsistentIndentationKind String optional
Indentation style for PSUseConsistentIndentation: space or tab.
Possible values: space, tab
-UseConsistentIndentationPipelineIndentation String optional
Pipeline indentation mode for PSUseConsistentIndentation.
Possible values: IncreaseIndentationAfterEveryPipeline, NoIndentation
-UseConsistentWhitespaceCheckInnerBrace SwitchParameter optional
For PSUseConsistentWhitespace: check inner brace spacing.
-UseConsistentWhitespaceCheckOpenBrace SwitchParameter optional
For PSUseConsistentWhitespace: check open brace spacing.
-UseConsistentWhitespaceCheckOpenParen SwitchParameter optional
For PSUseConsistentWhitespace: check open parenthesis spacing.
-UseConsistentWhitespaceCheckOperator SwitchParameter optional
For PSUseConsistentWhitespace: check operator spacing.
-UseConsistentWhitespaceCheckPipe SwitchParameter optional
For PSUseConsistentWhitespace: check pipeline operator spacing.
-UseConsistentWhitespaceCheckSeparator SwitchParameter optional
For PSUseConsistentWhitespace: check separator (comma) spacing.
-UseConsistentWhitespaceEnable SwitchParameter optional
Enable PSUseConsistentWhitespace rule and configure which elements to check.
-UseCorrectCasingEnable SwitchParameter optional
Enable PSUseCorrectCasing rule.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.