Public/Publish-PsModule.ps1
function Publish-PsModule { param ( $Path, $ApiKey, [switch]$IncrementVersion ) $moduleName = Split-Path $Path -Leaf $functions = Get-PsModuleFunctions $Path -PublicOnly if ($IncrementVersion) { $moduleFile = "$((Join-Path $path $moduleName)).psd1" $file = Import-PowerShellDataFile $moduleFile; [version]$version = ($file).ModuleVersion [version]$newVersion = "{0}.{1}.{2}" -f $version.Major, $version.Minor, ($version.Build + 1) Update-ModuleManifest -Path "$((Join-Path $Path $moduleName)).psd1" -FunctionsToExport $functions -ModuleVersion $newVersion; } else{ Update-ModuleManifest -Path "$((Join-Path $Path $moduleName)).psd1" -FunctionsToExport $functions; } Publish-Module -Path $Path -NugetAPIKey $ApiKey; Write-Host "Module $moduleName published"; } |