API Reference
Invoke-ModuleBuild
Creates/updates a module structure and triggers the build pipeline (legacy DSL compatible).
Remarks
This is the primary entry point for building a PowerShell module using PSPublishModule. Configuration is provided via a DSL using New-Configuration* cmdlets (typically inside the -Settings scriptblock) and then executed by the PowerForge pipeline runner. To generate a reusable powerforge.json configuration file (for the PowerForge CLI) without running any build steps, use -JsonOnly with -JsonPath. When running in an interactive terminal, pipeline execution uses a Spectre.Console progress UI. Redirect output or use -Verbose to force plain, line-by-line output (useful for CI logs). Dependency behavior is composed from the configuration segments you emit. Typically this means: New-ConfigurationModule declares dependencies, New-ConfigurationBuild decides whether the build host should install missing ones, and New-ConfigurationArtefact decides whether required modules should be bundled into the output artefact.
Examples
Build a module (DSL) and keep docs in sync
Invoke-ModuleBuild -ModuleName 'MyModule' -Path 'C:\Git' -Settings {
New-ConfigurationDocumentation -Enable -UpdateWhenNew -StartClean -Path 'Docs' -PathReadme 'Docs\Readme.md'
}
Generate a PowerForge JSON pipeline without running the build
Invoke-ModuleBuild -ModuleName 'MyModule' -Path 'C:\Git' -JsonOnly -JsonPath 'C:\Git\MyModule\powerforge.json'
Enforce consistency and compatibility during build (fail CI on issues)
Invoke-ModuleBuild -ModuleName 'MyModule' -Path 'C:\Git' -ExitCode -Settings {
New-ConfigurationFileConsistency -Enable -FailOnInconsistency -AutoFix -CreateBackups -ExportReport
New-ConfigurationCompatibility -Enable -RequireCrossCompatibility -FailOnIncompatibility -ExportReport
}
Publish a .NET project into the module as part of the build
Invoke-ModuleBuild -ModuleName 'MyModule' -Path 'C:\Git' `
-CsprojPath 'C:\Git\MyModule\src\MyModule\MyModule.csproj' -DotNetFramework net8.0 -DotNetConfiguration Release `
-Settings { New-ConfigurationBuild -Enable -MergeModuleOnBuild }
Fail CI only on new diagnostics compared to a committed baseline
Invoke-ModuleBuild -ModuleName 'MyModule' -Path 'C:\Git' `
-DiagnosticsBaselinePath 'C:\Git\MyModule\.powerforge\module-diagnostics-baseline.json' `
-FailOnNewDiagnostics -FailOnDiagnosticsSeverity Warning
Install missing dependencies during the build and bundle required modules into the package
Invoke-ModuleBuild -ModuleName 'MyModule' -Path 'C:\Git' -Settings {
New-ConfigurationModule -Type RequiredModule -Name 'Pester' -Version 'Latest' -Guid 'Auto'
New-ConfigurationBuild -Enable -InstallMissingModules -ResolveMissingModulesOnline
New-ConfigurationArtefact -Type Packed -Enable -AddRequiredModules -RequiredModulesSource Auto
}
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.
Syntax
Invoke-ModuleBuild [-AliasesToExportFolder <String>] [-CsprojPath <String>] [-DiagnosticsBaselinePath <String>] [-DiagnosticsBinaryConflictSearchRoot <String[]>] [-DotNetConfiguration <Release|Debug>] [-DotNetFramework <String[]>] [-ExcludeDirectories <String[]>] [-ExcludeFiles <String[]>] [-ExcludeFromPackage <String[]>] [-ExitCode] [-FailOnDiagnosticsSeverity <Warning|Error>] [-FailOnNewDiagnostics] [-FunctionsToExportFolder <String>] [-GenerateDiagnosticsBaseline] [-IncludeAll <String[]>] [-IncludeCustomCode <ScriptBlock>] [-IncludePS1 <String[]>] [-IncludeRoot <String[]>] [-IncludeToArray <IDictionary>] [-InstallRoots <String[]>] [-InstallStrategy <Exact|AutoRevision>] [-JsonOnly] [-JsonPath <String>] [-KeepStaging] [-KeepVersions <Int32>] [-Legacy] [-LegacyFlatHandling <Warn|Convert|Delete|Ignore>] [-LibrariesCore <String>] [-LibrariesDefault <String>] [-LibrariesStandard <String>] -ModuleName <String> [-NoInteractive] [-Path <String>] [-PreserveInstallVersions <String[]>] [-Settings <ScriptBlock>] [-SkipInstall] [-StagingPath <String>] [-UpdateDiagnosticsBaseline] [<CommonParameters>]
#
ModernParameters
- AliasesToExportFolder String
- Folder name containing aliases to export. Default: Public.
- CsprojPath String
- Optional path to a .NET project (.csproj) to publish into the module.
- DiagnosticsBaselinePath String
- Optional path to a diagnostics baseline file used to compare current issues with known issues.
- DiagnosticsBinaryConflictSearchRoot String[]
- Optional module roots to scan for deterministic binary conflict diagnostics. When provided, conflict findings can participate in diagnostics baselines and policy.
- DotNetConfiguration String
- Build configuration for publishing the .NET project (Release or Debug).
- Possible values:
Release,Debug - DotNetFramework String[]
- Target frameworks to publish (e.g., net472, net8.0).
- ExcludeDirectories String[]
- Directory names excluded from staging copy (matched by directory name, not by path).
- ExcludeFiles String[]
- File names excluded from staging copy (matched by file name, not by path).
- ExcludeFromPackage String[]
- Exclude patterns for artefact packaging.
- ExitCode SwitchParameter
- When specified, requests the host to exit with code 0 on success and 1 on failure.
- FailOnDiagnosticsSeverity Nullable`1
- Fails the build when diagnostics at or above the specified severity are present.
- Possible values:
Warning,Error - FailOnNewDiagnostics SwitchParameter
- Fails the build when diagnostics appear that are not present in the loaded baseline.
- FunctionsToExportFolder String
- Folder name containing functions to export. Default: Public.
- GenerateDiagnosticsBaseline SwitchParameter
- Writes a diagnostics baseline file from the current run.
- IncludeAll String[]
- Folders from which to include all files in artefacts.
- IncludeCustomCode ScriptBlock
- Optional script block executed during staging that can add custom files/folders to the build.
- IncludePS1 String[]
- Folders from which to include .ps1 files in artefacts.
- IncludeRoot String[]
- Include patterns for root files in artefacts.
- IncludeToArray IDictionary
- Advanced hashtable form for includes (maps IncludeRoot/IncludePS1/IncludeAll etc).
- InstallRoots String[]
- Destination module roots for install. When omitted, defaults are used.
- InstallStrategy InstallationStrategy
- Installation strategy used when installing the module.
- Possible values:
Exact,AutoRevision - JsonOnly SwitchParameter
- Generates a PowerForge pipeline JSON file and exits without running the build pipeline. Intended for migrating legacy DSL scripts to powerforge CLI configuration.
- JsonPath String
- Output path for the generated pipeline JSON file (used with JsonOnly). Defaults to powerforge.json in the project root.
- KeepStaging SwitchParameter
- Keep staging directory after build/install.
- KeepVersions Int32
- Number of versions to keep per module root when installing.
- Legacy SwitchParameter
- Compatibility switch. Historically forced the PowerShell-script build pipeline; the build now always runs through the C# PowerForge pipeline.
- LegacyFlatHandling LegacyFlatModuleHandling
- How to handle legacy flat installs found under module roots.
- Possible values:
Warn,Convert,Delete,Ignore - LibrariesCore String
- Alternate relative path for .NET Core-targeted libraries folder. Default: Lib/Core.
- LibrariesDefault String
- Alternate relative path for .NET Framework-targeted libraries folder. Default: Lib/Default.
- LibrariesStandard String
- Alternate relative path for .NET Standard-targeted libraries folder. Default: Lib/Standard.
- ModuleName String
- Name of the module being built.
- NoInteractive SwitchParameter
- Disables the interactive progress UI and emits plain log output.
- Path String
- Path to the parent folder where the project exists or should be created. The module project resolves to Path\ModuleName. When omitted, uses the parent of the calling script directory.
- PreserveInstallVersions String[]
- Version folders to preserve when pruning installed versions.
- Settings ScriptBlock
- Provides settings for the module in the form of a script block (DSL).
- SkipInstall SwitchParameter
- Skips installing the module after build.
- StagingPath String
- Staging directory for the PowerForge pipeline. When omitted, a temporary folder is generated.
- UpdateDiagnosticsBaseline SwitchParameter
- Updates a diagnostics baseline file from the current run.
Outputs
System.Object
Invoke-ModuleBuild -Configuration <IDictionary> [-DiagnosticsBaselinePath <String>] [-DiagnosticsBinaryConflictSearchRoot <String[]>] [-ExcludeDirectories <String[]>] [-ExcludeFiles <String[]>] [-ExitCode] [-FailOnDiagnosticsSeverity <Warning|Error>] [-FailOnNewDiagnostics] [-GenerateDiagnosticsBaseline] [-JsonOnly] [-JsonPath <String>] [-Legacy] [-NoInteractive] [-UpdateDiagnosticsBaseline] [<CommonParameters>]
#
ConfigurationParameters
- Configuration IDictionary
- Legacy configuration dictionary for backwards compatibility.
- DiagnosticsBaselinePath String
- Optional path to a diagnostics baseline file used to compare current issues with known issues.
- DiagnosticsBinaryConflictSearchRoot String[]
- Optional module roots to scan for deterministic binary conflict diagnostics. When provided, conflict findings can participate in diagnostics baselines and policy.
- ExcludeDirectories String[]
- Directory names excluded from staging copy (matched by directory name, not by path).
- ExcludeFiles String[]
- File names excluded from staging copy (matched by file name, not by path).
- ExitCode SwitchParameter
- When specified, requests the host to exit with code 0 on success and 1 on failure.
- FailOnDiagnosticsSeverity Nullable`1
- Fails the build when diagnostics at or above the specified severity are present.
- Possible values:
Warning,Error - FailOnNewDiagnostics SwitchParameter
- Fails the build when diagnostics appear that are not present in the loaded baseline.
- GenerateDiagnosticsBaseline SwitchParameter
- Writes a diagnostics baseline file from the current run.
- JsonOnly SwitchParameter
- Generates a PowerForge pipeline JSON file and exits without running the build pipeline. Intended for migrating legacy DSL scripts to powerforge CLI configuration.
- JsonPath String
- Output path for the generated pipeline JSON file (used with JsonOnly). Defaults to powerforge.json in the project root.
- Legacy SwitchParameter
- Compatibility switch. Historically forced the PowerShell-script build pipeline; the build now always runs through the C# PowerForge pipeline.
- NoInteractive SwitchParameter
- Disables the interactive progress UI and emits plain log output.
- UpdateDiagnosticsBaseline SwitchParameter
- Updates a diagnostics baseline file from the current run.
Outputs
System.Object