Evotec

Project

PSPublishModule

PSPublishModule is an open-source PowerShell and .NET project with packages, release history, and technical documentation.

Stars 43
Forks 13
Open issues 1
PowerShell Gallery downloads 13,876
Release v3.0.3
Language: C# Updated: 2026-04-14

API Reference

Cmdlet

Invoke-ModuleBuild

Namespace PSPublishModule
Inputs
None
Outputs
System.Object

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

Authored help example

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>]
#
Parameter set: Modern

Parameters

AliasesToExportFolder String optionalposition: namedpipeline: False
Folder name containing aliases to export. Default: Public.
CsprojPath String optionalposition: namedpipeline: False
Optional path to a .NET project (.csproj) to publish into the module.
DiagnosticsBaselinePath String optionalposition: namedpipeline: False
Optional path to a diagnostics baseline file used to compare current issues with known issues.
DiagnosticsBinaryConflictSearchRoot String[] optionalposition: namedpipeline: False
Optional module roots to scan for deterministic binary conflict diagnostics. When provided, conflict findings can participate in diagnostics baselines and policy.
DotNetConfiguration String optionalposition: namedpipeline: Falsevalues: 2
Build configuration for publishing the .NET project (Release or Debug).
Possible values: Release, Debug
DotNetFramework String[] optionalposition: namedpipeline: False
Target frameworks to publish (e.g., net472, net8.0).
ExcludeDirectories String[] optionalposition: namedpipeline: False
Directory names excluded from staging copy (matched by directory name, not by path).
ExcludeFiles String[] optionalposition: namedpipeline: False
File names excluded from staging copy (matched by file name, not by path).
ExcludeFromPackage String[] optionalposition: namedpipeline: False
Exclude patterns for artefact packaging.
ExitCode SwitchParameter optionalposition: namedpipeline: False
When specified, requests the host to exit with code 0 on success and 1 on failure.
FailOnDiagnosticsSeverity Nullable`1 optionalposition: namedpipeline: Falsevalues: 2
Fails the build when diagnostics at or above the specified severity are present.
Possible values: Warning, Error
FailOnNewDiagnostics SwitchParameter optionalposition: namedpipeline: False
Fails the build when diagnostics appear that are not present in the loaded baseline.
FunctionsToExportFolder String optionalposition: namedpipeline: False
Folder name containing functions to export. Default: Public.
GenerateDiagnosticsBaseline SwitchParameter optionalposition: namedpipeline: False
Writes a diagnostics baseline file from the current run.
IncludeAll String[] optionalposition: namedpipeline: False
Folders from which to include all files in artefacts.
IncludeCustomCode ScriptBlock optionalposition: namedpipeline: False
Optional script block executed during staging that can add custom files/folders to the build.
IncludePS1 String[] optionalposition: namedpipeline: False
Folders from which to include .ps1 files in artefacts.
IncludeRoot String[] optionalposition: namedpipeline: False
Include patterns for root files in artefacts.
IncludeToArray IDictionary optionalposition: namedpipeline: False
Advanced hashtable form for includes (maps IncludeRoot/IncludePS1/IncludeAll etc).
InstallRoots String[] optionalposition: namedpipeline: False
Destination module roots for install. When omitted, defaults are used.
InstallStrategy InstallationStrategy optionalposition: namedpipeline: Falsevalues: 2
Installation strategy used when installing the module.
Possible values: Exact, AutoRevision
JsonOnly SwitchParameter optionalposition: namedpipeline: False
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 optionalposition: namedpipeline: False
Output path for the generated pipeline JSON file (used with JsonOnly). Defaults to powerforge.json in the project root.
KeepStaging SwitchParameter optionalposition: namedpipeline: False
Keep staging directory after build/install.
KeepVersions Int32 optionalposition: namedpipeline: False
Number of versions to keep per module root when installing.
Legacy SwitchParameter optionalposition: namedpipeline: False
Compatibility switch. Historically forced the PowerShell-script build pipeline; the build now always runs through the C# PowerForge pipeline.
LegacyFlatHandling LegacyFlatModuleHandling optionalposition: namedpipeline: Falsevalues: 4
How to handle legacy flat installs found under module roots.
Possible values: Warn, Convert, Delete, Ignore
LibrariesCore String optionalposition: namedpipeline: False
Alternate relative path for .NET Core-targeted libraries folder. Default: Lib/Core.
LibrariesDefault String optionalposition: namedpipeline: False
Alternate relative path for .NET Framework-targeted libraries folder. Default: Lib/Default.
LibrariesStandard String optionalposition: namedpipeline: False
Alternate relative path for .NET Standard-targeted libraries folder. Default: Lib/Standard.
ModuleName String requiredposition: namedpipeline: Falsealiases: ProjectName
Name of the module being built.
NoInteractive SwitchParameter optionalposition: namedpipeline: False
Disables the interactive progress UI and emits plain log output.
Path String optionalposition: namedpipeline: False
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[] optionalposition: namedpipeline: False
Version folders to preserve when pruning installed versions.
Settings ScriptBlock optionalposition: 0pipeline: False
Provides settings for the module in the form of a script block (DSL).
SkipInstall SwitchParameter optionalposition: namedpipeline: False
Skips installing the module after build.
StagingPath String optionalposition: namedpipeline: False
Staging directory for the PowerForge pipeline. When omitted, a temporary folder is generated.
UpdateDiagnosticsBaseline SwitchParameter optionalposition: namedpipeline: False
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>]
#
Parameter set: Configuration

Parameters

Configuration IDictionary requiredposition: namedpipeline: False
Legacy configuration dictionary for backwards compatibility.
DiagnosticsBaselinePath String optionalposition: namedpipeline: False
Optional path to a diagnostics baseline file used to compare current issues with known issues.
DiagnosticsBinaryConflictSearchRoot String[] optionalposition: namedpipeline: False
Optional module roots to scan for deterministic binary conflict diagnostics. When provided, conflict findings can participate in diagnostics baselines and policy.
ExcludeDirectories String[] optionalposition: namedpipeline: False
Directory names excluded from staging copy (matched by directory name, not by path).
ExcludeFiles String[] optionalposition: namedpipeline: False
File names excluded from staging copy (matched by file name, not by path).
ExitCode SwitchParameter optionalposition: namedpipeline: False
When specified, requests the host to exit with code 0 on success and 1 on failure.
FailOnDiagnosticsSeverity Nullable`1 optionalposition: namedpipeline: Falsevalues: 2
Fails the build when diagnostics at or above the specified severity are present.
Possible values: Warning, Error
FailOnNewDiagnostics SwitchParameter optionalposition: namedpipeline: False
Fails the build when diagnostics appear that are not present in the loaded baseline.
GenerateDiagnosticsBaseline SwitchParameter optionalposition: namedpipeline: False
Writes a diagnostics baseline file from the current run.
JsonOnly SwitchParameter optionalposition: namedpipeline: False
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 optionalposition: namedpipeline: False
Output path for the generated pipeline JSON file (used with JsonOnly). Defaults to powerforge.json in the project root.
Legacy SwitchParameter optionalposition: namedpipeline: False
Compatibility switch. Historically forced the PowerShell-script build pipeline; the build now always runs through the C# PowerForge pipeline.
NoInteractive SwitchParameter optionalposition: namedpipeline: False
Disables the interactive progress UI and emits plain log output.
UpdateDiagnosticsBaseline SwitchParameter optionalposition: namedpipeline: False
Updates a diagnostics baseline file from the current run.

Outputs

System.Object