From 2843b1d160d3448d745b702b064ce7123097ee54 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Tue, 23 Sep 2025 09:48:56 -0500 Subject: [PATCH 01/18] Update Readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d56f40b..6ce71cc 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ The `resources` folder within the `src` directory is intended for including any - **Configuration files**: Store any JSON, XML, or other configuration files needed by your module. - **Script files**: Place any scripts that are used by your functions or modules, but are not directly part of the public or private functions. +- **formatdata files**: Store `Type.format.ps1xml` file for custom format data types to be imported to manifest - **Documentation files**: Include any supplementary documentation that supports the usage or development of the module. - **Data files**: Store any data files that are used by your module, such as CSV or JSON files. - **Subfolder**: Include any additional folders and their content to be included with the module, such as dependant Modules, APIs, DLLs, etc... organized by a subfolder. From 519af99068c21818ae1f4dfc5baec9072d372fe1 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Wed, 4 Mar 2026 10:39:07 -0600 Subject: [PATCH 02/18] Support importing types.ps1xml files to manifest --- README.md | 3 ++- project.json | 2 +- src/private/Build.Manifest.ps1 | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6ce71cc..af4541d 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,8 @@ The `resources` folder within the `src` directory is intended for including any - **Configuration files**: Store any JSON, XML, or other configuration files needed by your module. - **Script files**: Place any scripts that are used by your functions or modules, but are not directly part of the public or private functions. -- **formatdata files**: Store `Type.format.ps1xml` file for custom format data types to be imported to manifest +- **formatdata files**: Store `Example.Format.ps1xml` file for custom format data types to be imported to manifest +- **types files**: Store `Example.Types.ps1xml` file for custom format data types to be imported to manifest - **Documentation files**: Include any supplementary documentation that supports the usage or development of the module. - **Data files**: Store any data files that are used by your module, such as CSV or JSON files. - **Subfolder**: Include any additional folders and their content to be included with the module, such as dependant Modules, APIs, DLLs, etc... organized by a subfolder. diff --git a/project.json b/project.json index c400f70..9e89dc6 100644 --- a/project.json +++ b/project.json @@ -1,7 +1,7 @@ { "ProjectName": "ModuleTools", "Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.", - "Version": "1.3.0", + "Version": "1.4.0", "copyResourcesToModuleRoot": false, "Manifest": { "Author": "Manjunath Beli", diff --git a/src/private/Build.Manifest.ps1 b/src/private/Build.Manifest.ps1 index c127374..ab02112 100644 --- a/src/private/Build.Manifest.ps1 +++ b/src/private/Build.Manifest.ps1 @@ -12,9 +12,9 @@ function Build-Manifest { $aliasToExport += Get-AliasInFunctionFromFile -filePath $_ } - ## Import Formatting (if any) + ## Import Format.ps1xml (if any) $FormatsToProcess = @() - Get-ChildItem -Path $data.ResourcesDir -File -Filter '*.ps1xml' -ErrorAction SilentlyContinue | ForEach-Object { + Get-ChildItem -Path $data.ResourcesDir -File -Filter '*Format.ps1xml' -ErrorAction SilentlyContinue | ForEach-Object { if ($data.copyResourcesToModuleRoot) { $FormatsToProcess += $_.Name } else { @@ -22,6 +22,16 @@ function Build-Manifest { } } + ## Import Types.ps1xml1 (if any) + $FormatsToProcess = @() + Get-ChildItem -Path $data.ResourcesDir -File -Filter '*Types.ps1xml' -ErrorAction SilentlyContinue | ForEach-Object { + if ($data.copyResourcesToModuleRoot) { + $TypesToProcess += $_.Name + } else { + $TypesToProcess += Join-Path -Path 'resources' -ChildPath $_.Name + } + } + $ManfiestAllowedParams = (Get-Command New-ModuleManifest).Parameters.Keys $sv = [semver]$data.Version $ParmsManifest = @{ From ca616bcdbcbb226d92b940f2b8d7d654efc4af0a Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Wed, 4 Mar 2026 10:43:59 -0600 Subject: [PATCH 03/18] Docs update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af4541d..7f88f5a 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ The `resources` folder within the `src` directory is intended for including any - **Configuration files**: Store any JSON, XML, or other configuration files needed by your module. - **Script files**: Place any scripts that are used by your functions or modules, but are not directly part of the public or private functions. - **formatdata files**: Store `Example.Format.ps1xml` file for custom format data types to be imported to manifest -- **types files**: Store `Example.Types.ps1xml` file for custom format data types to be imported to manifest +- **types files**: Store `Example.Types.ps1xml` file for custom types data types to be imported to manifest - **Documentation files**: Include any supplementary documentation that supports the usage or development of the module. - **Data files**: Store any data files that are used by your module, such as CSV or JSON files. - **Subfolder**: Include any additional folders and their content to be included with the module, such as dependant Modules, APIs, DLLs, etc... organized by a subfolder. From 3775af79fb2f42ab736cf2b9dad646cbf39bb851 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Wed, 4 Mar 2026 10:48:12 -0600 Subject: [PATCH 04/18] Fix custom object for typestoprocess --- project.json | 2 +- src/private/Build.Manifest.ps1 | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/project.json b/project.json index 9e89dc6..08e84bf 100644 --- a/project.json +++ b/project.json @@ -1,7 +1,7 @@ { "ProjectName": "ModuleTools", "Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.", - "Version": "1.4.0", + "Version": "1.4.1", "copyResourcesToModuleRoot": false, "Manifest": { "Author": "Manjunath Beli", diff --git a/src/private/Build.Manifest.ps1 b/src/private/Build.Manifest.ps1 index ab02112..fd3b1ca 100644 --- a/src/private/Build.Manifest.ps1 +++ b/src/private/Build.Manifest.ps1 @@ -23,7 +23,7 @@ function Build-Manifest { } ## Import Types.ps1xml1 (if any) - $FormatsToProcess = @() + $TypesToProcess = @() Get-ChildItem -Path $data.ResourcesDir -File -Filter '*Types.ps1xml' -ErrorAction SilentlyContinue | ForEach-Object { if ($data.copyResourcesToModuleRoot) { $TypesToProcess += $_.Name @@ -42,6 +42,7 @@ function Build-Manifest { RootModule = "$($data.ProjectName).psm1" ModuleVersion = [version]$sv FormatsToProcess = $FormatsToProcess + TypesToProcess = $TypesToProcess } ## Release lable From b8d0431bf0ae6aa74f4de14bfc6c4fa570df9f64 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Fri, 13 Mar 2026 10:38:13 -0500 Subject: [PATCH 05/18] Local Module Publishing --- project.json | 2 +- src/private/GetLocalModulePath.ps1 | 24 ++++++++++++++++++++++++ src/public/PublishMTLocal.ps1 | 28 ++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/private/GetLocalModulePath.ps1 create mode 100644 src/public/PublishMTLocal.ps1 diff --git a/project.json b/project.json index 08e84bf..be7ace8 100644 --- a/project.json +++ b/project.json @@ -1,7 +1,7 @@ { "ProjectName": "ModuleTools", "Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.", - "Version": "1.4.1", + "Version": "1.5.0", "copyResourcesToModuleRoot": false, "Manifest": { "Author": "Manjunath Beli", diff --git a/src/private/GetLocalModulePath.ps1 b/src/private/GetLocalModulePath.ps1 new file mode 100644 index 0000000..6712f8c --- /dev/null +++ b/src/private/GetLocalModulePath.ps1 @@ -0,0 +1,24 @@ +function Get-LocalModulePath { + $sep = [IO.Path]::PathSeparator + + $ModulePaths = $env:PSModulePath -split $sep | ForEach-Object { $_.Trim() } | Select-Object -Unique + + if ($IsWindows) { + $MatchPattern = '\\Documents\\PowerShell\\Modules' + $Result = $ModulePaths | Where-Object { $_ -match $MatchPattern } | Select-Object -First 1 + if ($Result -and (Test-Path $Result)) { + return $Result + } else { + throw "No windows module path matching $MatchPattern found" + } + } else { + # For Mac and Linux + $MatchPattern = '/\.local/share/powershell/Modules$' + $Result = $ModulePaths | Where-Object { $_ -match $MatchPattern } | Select-Object -First 1 + if ($Result -and (Test-Path $Result)) { + return $Result + } else { + throw "No macOS/Linux module path matching $MatchPattern found in PSModulePath." + } + } +} \ No newline at end of file diff --git a/src/public/PublishMTLocal.ps1 b/src/public/PublishMTLocal.ps1 new file mode 100644 index 0000000..c13d899 --- /dev/null +++ b/src/public/PublishMTLocal.ps1 @@ -0,0 +1,28 @@ +function Publish-MTLocal { + [CmdletBinding()] + param( + [string]$ModuleDirectoryPath + ) + + if ($ModuleDirectoryPath -and (-not (Test-Path $ModuleDirectoryPath -PathType Container)) ) { + New-Item $ModuleDirectoryPath -ItemType Directory -Force + } else { + $ModuleDirectoryPath = Get-LocalModulePath + } + + $ProjectInfo = Get-MTProjectInfo + + # Ensure module is locally built and ready + if (-not (Test-Path $ProjectInfo.OutputModuleDir)) { + trhow 'Dist folder is empty, build the module before running publish command' + } + + # Cleanup old files + $OldModule = Join-Path -Path $ModuleDirectoryPath -ChildPath $ProjectInfo.ProjectName + if (Test-Path -Path $OldModule) { + Remove-Item -Recurse $OldModule -Force + } + + # Copy New Files + Copy-Item -Path $ProjectInfo.OutputModuleDir -Destination $ModuleDirectoryPath -Recurse -ErrorAction Stop +} \ No newline at end of file From 2abea599297e0d0de8cc839bdaf66fa1659ddd2c Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Fri, 13 Mar 2026 10:44:18 -0500 Subject: [PATCH 06/18] Local Module Publishing with input param --- src/public/PublishMTLocal.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/public/PublishMTLocal.ps1 b/src/public/PublishMTLocal.ps1 index c13d899..e9f7418 100644 --- a/src/public/PublishMTLocal.ps1 +++ b/src/public/PublishMTLocal.ps1 @@ -4,8 +4,10 @@ function Publish-MTLocal { [string]$ModuleDirectoryPath ) - if ($ModuleDirectoryPath -and (-not (Test-Path $ModuleDirectoryPath -PathType Container)) ) { - New-Item $ModuleDirectoryPath -ItemType Directory -Force + if ($ModuleDirectoryPath) { + if (-not (Test-Path $ModuleDirectoryPath -PathType Container)) { + New-Item $ModuleDirectoryPath -ItemType Directory -Force | Out-Null + } } else { $ModuleDirectoryPath = Get-LocalModulePath } From e374cdc227853076b5061a445984618c2200833f Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Fri, 13 Mar 2026 12:14:20 -0500 Subject: [PATCH 07/18] Add verbose --- src/public/PublishMTLocal.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/public/PublishMTLocal.ps1 b/src/public/PublishMTLocal.ps1 index e9f7418..5fdba54 100644 --- a/src/public/PublishMTLocal.ps1 +++ b/src/public/PublishMTLocal.ps1 @@ -12,6 +12,8 @@ function Publish-MTLocal { $ModuleDirectoryPath = Get-LocalModulePath } + Write-Verbose "Using $ModuleDirectoryPath as path" + $ProjectInfo = Get-MTProjectInfo # Ensure module is locally built and ready @@ -22,9 +24,12 @@ function Publish-MTLocal { # Cleanup old files $OldModule = Join-Path -Path $ModuleDirectoryPath -ChildPath $ProjectInfo.ProjectName if (Test-Path -Path $OldModule) { + Write-Verbose 'Removing old module files' Remove-Item -Recurse $OldModule -Force } # Copy New Files + Write-Verbose 'Copying new Files' Copy-Item -Path $ProjectInfo.OutputModuleDir -Destination $ModuleDirectoryPath -Recurse -ErrorAction Stop + Write-Verbose 'Module copy to local path complete, Refresh session or import module manually' } \ No newline at end of file From 85c6f4a326ad373e190387f9869eacbfa0534eb1 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Mon, 16 Mar 2026 10:10:21 -0500 Subject: [PATCH 08/18] Typo fix --- project.json | 2 +- src/public/PublishMTLocal.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project.json b/project.json index be7ace8..d9fdb63 100644 --- a/project.json +++ b/project.json @@ -1,7 +1,7 @@ { "ProjectName": "ModuleTools", "Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.", - "Version": "1.5.0", + "Version": "1.5.1", "copyResourcesToModuleRoot": false, "Manifest": { "Author": "Manjunath Beli", diff --git a/src/public/PublishMTLocal.ps1 b/src/public/PublishMTLocal.ps1 index 5fdba54..ef786ad 100644 --- a/src/public/PublishMTLocal.ps1 +++ b/src/public/PublishMTLocal.ps1 @@ -18,7 +18,7 @@ function Publish-MTLocal { # Ensure module is locally built and ready if (-not (Test-Path $ProjectInfo.OutputModuleDir)) { - trhow 'Dist folder is empty, build the module before running publish command' + throw 'Dist folder is empty, build the module before running publish command' } # Cleanup old files From 04066442eec8d60568e1b810e9394b39195ae0f1 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Wed, 18 Mar 2026 10:45:19 -0500 Subject: [PATCH 09/18] Include Build-Help to generate docs using platyps --- project.json | 2 +- src/private/BuildHelp.ps1 | 37 +++++++++++++++++++ .../{Build.Manifest.ps1 => BuildManifest.ps1} | 0 .../{Build-Module.ps1 => BuildModule.ps1} | 0 src/public/GetMTProjectInfo.ps1 | 1 + src/public/InvokeMTBuild.ps1 | 1 + 6 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/private/BuildHelp.ps1 rename src/private/{Build.Manifest.ps1 => BuildManifest.ps1} (100%) rename src/private/{Build-Module.ps1 => BuildModule.ps1} (100%) diff --git a/project.json b/project.json index d9fdb63..2d43cfc 100644 --- a/project.json +++ b/project.json @@ -1,7 +1,7 @@ { "ProjectName": "ModuleTools", "Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.", - "Version": "1.5.1", + "Version": "1.5.2", "copyResourcesToModuleRoot": false, "Manifest": { "Author": "Manjunath Beli", diff --git a/src/private/BuildHelp.ps1 b/src/private/BuildHelp.ps1 new file mode 100644 index 0000000..8c833fb --- /dev/null +++ b/src/private/BuildHelp.ps1 @@ -0,0 +1,37 @@ +function Build-Help { + [CmdletBinding()] + param( + ) + Write-Verbose 'Running Help update' + + $data = Get-MTProjectInfo + $helpMarkdownFiles = Get-ChildItem -Path $data.DocsDir -Filter '*.md' -Recurse + + if (-not $helpMarkdownFiles) { + Write-Verbose 'No help markdown files in docs directory, skipping building help' + return + } + + #region Check PlatyPS version requirement + $minVersion = [version]'1.0.1' + $module = Get-Module -ListAvailable -Name Microsoft.PowerShell.PlatyPS | Sort-Object Version -Descending | Select-Object -First 1 + if (-not $module -or $module.Version -lt $minVersion) { + throw 'Microsoft.PowerShell.PlatyPS version 1.0.1 or higher is required.' + } + #endregion + + $AllCommandHelpFiles = $helpMarkdownFiles | Measure-PlatyPSMarkdown | Where-Object FileType -Match CommandHelp + + # Export to Dist folder + $AllCommandHelpFiles | Import-MarkdownCommandHelp -Path { $_.FilePath } | + Export-MamlCommandHelp -OutputFolder $data.OutputModuleDir | Out-Null + + # Rename the directory to match locale + $HelpDirOld = Join-Path $data.OutputModuleDir $Data.ProjectName + #TODO: hardcoded locale to en-US, change it based on Doc type + $languageLocale = 'en-US' + $HelpDirNew = Join-Path $data.OutputModuleDir $languageLocale + Write-Verbose "Renamed folder to locale: $languageLocale" + + Rename-Item -Path $HelpDirOld -NewName $HelpDirNew +} \ No newline at end of file diff --git a/src/private/Build.Manifest.ps1 b/src/private/BuildManifest.ps1 similarity index 100% rename from src/private/Build.Manifest.ps1 rename to src/private/BuildManifest.ps1 diff --git a/src/private/Build-Module.ps1 b/src/private/BuildModule.ps1 similarity index 100% rename from src/private/Build-Module.ps1 rename to src/private/BuildModule.ps1 diff --git a/src/public/GetMTProjectInfo.ps1 b/src/public/GetMTProjectInfo.ps1 index 23c9f88..8964dbb 100644 --- a/src/public/GetMTProjectInfo.ps1 +++ b/src/public/GetMTProjectInfo.ps1 @@ -37,6 +37,7 @@ function Get-MTProjectInfo { $Out['PrivateDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'private') $Out['ClassesDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'classes') $Out['ResourcesDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'resources') + $Out['DocsDir'] = [System.IO.Path]::Join($ProjectRoot, 'docs') $Out['OutputDir'] = [System.IO.Path]::Join($ProjectRoot, 'dist') $Out['OutputModuleDir'] = [System.IO.Path]::Join($Out.OutputDir, $ProjectName) $Out['ModuleFilePSM1'] = [System.IO.Path]::Join($Out.OutputModuleDir, "$ProjectName.psm1") diff --git a/src/public/InvokeMTBuild.ps1 b/src/public/InvokeMTBuild.ps1 index b9c6fee..0947c81 100644 --- a/src/public/InvokeMTBuild.ps1 +++ b/src/public/InvokeMTBuild.ps1 @@ -20,5 +20,6 @@ function Invoke-MTBuild { Reset-ProjectDist Build-Module Build-Manifest + Build-Help Copy-ProjectResource } \ No newline at end of file From c771df1514eb3aa14d8a7fe9f5a31ed5f079b001 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Wed, 18 Mar 2026 10:57:32 -0500 Subject: [PATCH 10/18] Closes #18 - fix validation --- src/private/BuildHelp.ps1 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/private/BuildHelp.ps1 b/src/private/BuildHelp.ps1 index 8c833fb..e3a527b 100644 --- a/src/private/BuildHelp.ps1 +++ b/src/private/BuildHelp.ps1 @@ -12,13 +12,9 @@ function Build-Help { return } - #region Check PlatyPS version requirement - $minVersion = [version]'1.0.1' - $module = Get-Module -ListAvailable -Name Microsoft.PowerShell.PlatyPS | Sort-Object Version -Descending | Select-Object -First 1 - if (-not $module -or $module.Version -lt $minVersion) { - throw 'Microsoft.PowerShell.PlatyPS version 1.0.1 or higher is required.' + if (-not (Get-Module -Name Microsoft.PowerShell.PlatyPS -ListAvailable)) { + throw 'The module Microsoft.PowerShell.PlatyPS must be installed for Markdown documentation to be generated.' } - #endregion $AllCommandHelpFiles = $helpMarkdownFiles | Measure-PlatyPSMarkdown | Where-Object FileType -Match CommandHelp From bd0e0d0375b3285de0978a7522298a0a495728e3 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Wed, 18 Mar 2026 11:40:08 -0500 Subject: [PATCH 11/18] update Readme page with docs generation --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 7f88f5a..09e7468 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,16 @@ Generated module is stored in dist folder, you can easily import it or publish i └──  TestModule.psm1 ``` +### Docs Folder + +Store `Microsoft.PowerShell.PlatyPs` generated markdown files in `docs` folder. If `docs` folder exists and contain valid markdown files, Build will generate MAML help file in the built module. + +``` + docs +├──  ModuleTools.md +└──  Invoke-MTBuild.md +``` + ### Project JSON File The `project.json` file contains all the important details about your module and is used during the module build. It should comply with a specific schema. You can refer to the sample `project-sample.json` file in the `example` directory for guidance. From 4dc5da2463a6df66e3cd3e0862f871b8dd3edff4 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Wed, 18 Mar 2026 11:40:39 -0500 Subject: [PATCH 12/18] New minor release --- project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.json b/project.json index 2d43cfc..01f164c 100644 --- a/project.json +++ b/project.json @@ -1,7 +1,7 @@ { "ProjectName": "ModuleTools", "Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.", - "Version": "1.5.2", + "Version": "1.6.0", "copyResourcesToModuleRoot": false, "Manifest": { "Author": "Manjunath Beli", From 697b7746068f90c803608cb7044d535e7ce8492a Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Thu, 19 Mar 2026 13:00:44 -0500 Subject: [PATCH 13/18] Help for module through playtps --- docs/ModuleTools/Get-MTProjectInfo.md | 77 +++++++++ docs/ModuleTools/Invoke-MTBuild.md | 65 ++++++++ docs/ModuleTools/Invoke-MTTest.md | 112 +++++++++++++ docs/ModuleTools/ModuleTools.md | 44 +++++ docs/ModuleTools/New-MTModule.md | 129 ++++++++++++++ docs/ModuleTools/Publish-MTLocal.md | 92 ++++++++++ docs/ModuleTools/Update-MTModuleVersion.md | 185 +++++++++++++++++++++ project.json | 2 +- src/public/GetMTProjectInfo.ps1 | 46 ++--- src/public/InvokeMTBuild.ps1 | 14 -- src/public/InvokeMTTests.ps1 | 25 --- src/public/NewMTModule.ps1 | 17 -- src/public/UpdateModVersion.ps1 | 29 +--- 13 files changed, 725 insertions(+), 112 deletions(-) create mode 100644 docs/ModuleTools/Get-MTProjectInfo.md create mode 100644 docs/ModuleTools/Invoke-MTBuild.md create mode 100644 docs/ModuleTools/Invoke-MTTest.md create mode 100644 docs/ModuleTools/ModuleTools.md create mode 100644 docs/ModuleTools/New-MTModule.md create mode 100644 docs/ModuleTools/Publish-MTLocal.md create mode 100644 docs/ModuleTools/Update-MTModuleVersion.md diff --git a/docs/ModuleTools/Get-MTProjectInfo.md b/docs/ModuleTools/Get-MTProjectInfo.md new file mode 100644 index 0000000..4de9e02 --- /dev/null +++ b/docs/ModuleTools/Get-MTProjectInfo.md @@ -0,0 +1,77 @@ +--- +document type: cmdlet +external help file: ModuleTools-Help.xml +HelpUri: '' +Locale: en-US +Module Name: ModuleTools +ms.date: 03/19/2026 +PlatyPS schema version: 2024-05-01 +title: Get-MTProjectInfo +--- + +# Get-MTProjectInfo + +## SYNOPSIS + +Retrieves information about a project by reading data from a project.json file in ModuleTools project folder. + +## SYNTAX + +### __AllParameterSets + +``` +Get-MTProjectInfo [[-Path] ] [] +``` + +## ALIASES + +## DESCRIPTION + +The Get-MTProjectInfo function retrieves information about a project by reading data from a project.json file located in the current directory. +Ensure you navigate to a module directory which has project.json in root directory. +Most variables are already defined in output of this command which can be used in pester tests and other configs. + +## EXAMPLES + +### EXAMPLE 1 + +Get-MTProjectInfo +Retrieves project information from the project.json file in the current directory. Useful for debuggin and writing pester tests. + +## PARAMETERS + +### -Path + +Provide path to root folder of the ModuleTool based project + +```yaml +Type: System.String +DefaultValue: '' +SupportsWildcards: false +Aliases: [] +ParameterSets: +- Name: (All) + Position: 0 + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +## INPUTS + +## OUTPUTS + +### hastable with all project data. + +{{ Fill in the Description }} + +## NOTES + +## RELATED LINKS + +{{ Fill in the related links here }} + diff --git a/docs/ModuleTools/Invoke-MTBuild.md b/docs/ModuleTools/Invoke-MTBuild.md new file mode 100644 index 0000000..322677f --- /dev/null +++ b/docs/ModuleTools/Invoke-MTBuild.md @@ -0,0 +1,65 @@ +--- +document type: cmdlet +external help file: ModuleTools-Help.xml +HelpUri: '' +Locale: en-US +Module Name: ModuleTools +ms.date: 03/19/2026 +PlatyPS schema version: 2024-05-01 +title: Invoke-MTBuild +--- + +# Invoke-MTBuild + +## SYNOPSIS + +Build a ModuleTool project to generate ready to import PowerShell Module. + +## SYNTAX + +### __AllParameterSets + +``` +Invoke-MTBuild [] +``` + +## ALIASES + +This cmdlet has the following aliases, + {{Insert list of aliases}} + +## DESCRIPTION + +This function is used to build a module, dist folder is cleaned up and whole module is build from scracth. +copies all necessary resource files. + +## EXAMPLES + +### EXAMPLE 1 + +Invoke-MTBuild +Builds module from the project files. + +### EXAMPLE 2 + +Invoke-MTBuild -Verbose +Builds module and outputs verbose details during entire workflow. + +## PARAMETERS + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, +-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, +-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +{{ Fill in the related links here }} \ No newline at end of file diff --git a/docs/ModuleTools/Invoke-MTTest.md b/docs/ModuleTools/Invoke-MTTest.md new file mode 100644 index 0000000..a2feab1 --- /dev/null +++ b/docs/ModuleTools/Invoke-MTTest.md @@ -0,0 +1,112 @@ +--- +document type: cmdlet +external help file: ModuleTools-Help.xml +HelpUri: '' +Locale: en-US +Module Name: ModuleTools +ms.date: 03/19/2026 +PlatyPS schema version: 2024-05-01 +title: Invoke-MTTest +--- + +# Invoke-MTTest + +## SYNOPSIS + +Runs Pester tests using settings from project.json + +## SYNTAX + +### __AllParameterSets + +``` +Invoke-MTTest [[-TagFilter] ] [[-ExcludeTagFilter] ] [] +``` + +## ALIASES + +This cmdlet has the following aliases, + {{Insert list of aliases}} + +## DESCRIPTION + +Run Pester tests using the specified configuration and settings as defined in project.json. Place all your tests in "tests" folder + +## EXAMPLES + +### EXAMPLE 1 + +Invoke-MTTest +Runs the Pester tests for the project. + +### EXAMPLE 2 + +Invoke-MTTest -TagFilter "unit","integrate" +Runs the Pester tests for the project, that has tag unit or integrate + +### EXAMPLE 3 + +Invoke-MTTest -ExcludeTagFilter "unit" +Runs the Pester tests for the project, excludes any test with tag unit + +## PARAMETERS + +### -ExcludeTagFilter + +Array of tags to exclude, Provide the tag Pester should exclude + +```yaml +Type: System.String[] +DefaultValue: '' +SupportsWildcards: false +Aliases: [] +ParameterSets: +- Name: (All) + Position: 1 + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### -TagFilter + +Array of tags to run, Provide the tag Pester should run + +```yaml +Type: System.String[] +DefaultValue: '' +SupportsWildcards: false +Aliases: [] +ParameterSets: +- Name: (All) + Position: 0 + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, +-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, +-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +{{ Fill in the related links here }} + diff --git a/docs/ModuleTools/ModuleTools.md b/docs/ModuleTools/ModuleTools.md new file mode 100644 index 0000000..0b08230 --- /dev/null +++ b/docs/ModuleTools/ModuleTools.md @@ -0,0 +1,44 @@ +--- +document type: module +Help Version: 1.0.0.0 +HelpInfoUri: '' +Locale: en-US +Module Guid: d1595b4a-a79f-4440-94f0-3196f4d29c41 +Module Name: ModuleTools +ms.date: 03/19/2026 +PlatyPS schema version: 2024-05-01 +title: ModuleTools Module +--- + +# ModuleTools Module + +## Description + +ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation. + +## ModuleTools Cmdlets + +### [Get-MTProjectInfo](Get-MTProjectInfo.md) + +Retrieves information about a project by reading data from a project.json file in ModuleTools project folder. + +### [Invoke-MTBuild](Invoke-MTBuild.md) + +Build a ModuleTool project to generate ready to import PowerShell Module. + +### [Invoke-MTTest](Invoke-MTTest.md) + +Runs Pester tests using settings from project.json + +### [New-MTModule](New-MTModule.md) + +Create module scaffolding along with project.json file to easily build and manage modules in ModuleTools opinionated format + +### [Publish-MTLocal](Publish-MTLocal.md) + +Copy built module to local PSModulePath. + +### [Update-MTModuleVersion](Update-MTModuleVersion.md) + +Updates the version number of a module in project.json file. Uses [semver] object type. + diff --git a/docs/ModuleTools/New-MTModule.md b/docs/ModuleTools/New-MTModule.md new file mode 100644 index 0000000..5186d3f --- /dev/null +++ b/docs/ModuleTools/New-MTModule.md @@ -0,0 +1,129 @@ +--- +document type: cmdlet +external help file: ModuleTools-Help.xml +HelpUri: '' +Locale: en-US +Module Name: ModuleTools +ms.date: 03/19/2026 +PlatyPS schema version: 2024-05-01 +title: New-MTModule +--- + +# New-MTModule + +## SYNOPSIS + +Create module scaffolding along with project.json file to easily build and manage modules in ModuleTools opinionated format + +## SYNTAX + +### __AllParameterSets + +``` +New-MTModule [[-Path] ] [-WhatIf] [-Confirm] [] +``` + +## ALIASES + +This cmdlet has the following aliases, + {{Insert list of aliases}} + +## DESCRIPTION + +This command creates folder structure and project.json file easily. Use this to quikcly setup a ModuleTools compatible module. Provide all the paramters to command or enter details in the interactive prompts with sane defaults. + +## EXAMPLES + +### EXAMPLE 1 + +New-MTModule -Path c:\work +Creates module inside c:\work folder + +## PARAMETERS + +### -Confirm + +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +DefaultValue: '' +SupportsWildcards: false +Aliases: +- cf +ParameterSets: +- Name: (All) + Position: Named + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### -Path + +Path where module will be created. + +```yaml +Type: System.String +DefaultValue: (Get-Location).Path +SupportsWildcards: false +Aliases: [] +ParameterSets: +- Name: (All) + Position: 0 + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### -WhatIf + +Runs the command in a mode that only reports what would happen without performing the actions. + +```yaml +Type: System.Management.Automation.SwitchParameter +DefaultValue: '' +SupportsWildcards: false +Aliases: +- wi +ParameterSets: +- Name: (All) + Position: Named + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, +-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, +-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +The structure of the ModuleTools module is meticulously designed according to PowerShell best practices for module development. +While some design decisions may seem unconventional, they are made to ensure that ModuleTools and the process of building modules remain straightforward and easy to manage. + + +## RELATED LINKS + +{{ Fill in the related links here }} + diff --git a/docs/ModuleTools/Publish-MTLocal.md b/docs/ModuleTools/Publish-MTLocal.md new file mode 100644 index 0000000..98dc8fe --- /dev/null +++ b/docs/ModuleTools/Publish-MTLocal.md @@ -0,0 +1,92 @@ +--- +document type: cmdlet +external help file: ModuleTools-Help.xml +HelpUri: '' +Locale: en-US +Module Name: ModuleTools +ms.date: 03/19/2026 +PlatyPS schema version: 2024-05-01 +title: Publish-MTLocal +--- + +# Publish-MTLocal + +## SYNOPSIS + +Copy built module to local PSModulePath. + +## SYNTAX + +### __AllParameterSets + +``` +Publish-MTLocal [[-ModuleDirectoryPath] ] [] +``` + +## ALIASES + +This cmdlet has the following aliases, + {{Insert list of aliases}} + +## DESCRIPTION + +Useful quick testing and private modules which don't get hosted in PSGallery or other repository. This command publishes the generated module to local PSModulePath location which gets autoimported when porfile loads. + +## EXAMPLES + +### Example 1 + +Publish-MTLocal +Publishes to local $PSModulePath + +### Example 2 + +Publish-MTLocal -ModuleDirectoryPath \\Some\Path +Publishes/Copies to path provided + +## PARAMETERS + +### -ModuleDirectoryPath + +Path to save the built module. + +```yaml +Type: System.String +DefaultValue: '' +SupportsWildcards: false +Aliases: [] +ParameterSets: +- Name: (All) + Position: 0 + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, +-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, +-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### System.Object + +{{ Fill in the Description }} + +## NOTES + +{{ Fill in the Notes }} + +## RELATED LINKS + +{{ Fill in the related links here }} + diff --git a/docs/ModuleTools/Update-MTModuleVersion.md b/docs/ModuleTools/Update-MTModuleVersion.md new file mode 100644 index 0000000..8d66518 --- /dev/null +++ b/docs/ModuleTools/Update-MTModuleVersion.md @@ -0,0 +1,185 @@ +--- +document type: cmdlet +external help file: ModuleTools-Help.xml +HelpUri: '' +Locale: en-US +Module Name: ModuleTools +ms.date: 03/19/2026 +PlatyPS schema version: 2024-05-01 +title: Update-MTModuleVersion +--- + +# Update-MTModuleVersion + +## SYNOPSIS + +Updates the version number of a module in project.json file. Uses [semver] object type. + +## SYNTAX + +### __AllParameterSets + +``` +Update-MTModuleVersion [[-Label] ] [-PreviewRelease] [-StableRelease] [-WhatIf] [-Confirm] + [] +``` + +## ALIASES + +This cmdlet has the following aliases, + {{Insert list of aliases}} + +## DESCRIPTION + +This script updates the version number of a PowerShell module by modifying the project.json file, which gets written into module manifest file (.psd1). +[semver] is supported only powershell 7 and above. +It increments the version number based on the specified version part (Major, Minor, Patch). +Can also attach preview/stable release to Release property + +## EXAMPLES + +### EXAMPLE 1 + +Update-MTModuleVersion -Label Major +Updates the Major version part of the module. Version 2.1.3 will become 3.0.0. + +### EXAMPLE 2 + +Update-MTModuleVersion +Updates the Patch version part of the module. Version 2.1.3 will become 2.1.4 + +### EXAMPLE 3 + +Update-MTModuleVersion -PreviewRelease +Updates the Patch version part of the module. Version 2.1.6 will become 2.1.7-preview + +## PARAMETERS + +### -Confirm + +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +DefaultValue: '' +SupportsWildcards: false +Aliases: +- cf +ParameterSets: +- Name: (All) + Position: Named + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### -Label + +The part of the version number to increment (Major, Minor, Patch). +Default is patch. + +```yaml +Type: System.String +DefaultValue: Patch +SupportsWildcards: false +Aliases: [] +ParameterSets: +- Name: (All) + Position: 0 + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### -PreviewRelease + +Use this to use semantic version and attach release name as 'preview' which is supported by PowerShell gallery, to remove it use stable release parameter + +```yaml +Type: System.Management.Automation.SwitchParameter +DefaultValue: False +SupportsWildcards: false +Aliases: [] +ParameterSets: +- Name: (All) + Position: Named + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### -StableRelease + +Use this to use semantic version and removes 'preview' release name converting it to stable release + +```yaml +Type: System.Management.Automation.SwitchParameter +DefaultValue: False +SupportsWildcards: false +Aliases: [] +ParameterSets: +- Name: (All) + Position: Named + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### -WhatIf + +Runs the command in a mode that only reports what would happen without performing the actions. + +```yaml +Type: System.Management.Automation.SwitchParameter +DefaultValue: '' +SupportsWildcards: false +Aliases: +- wi +ParameterSets: +- Name: (All) + Position: Named + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, +-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, +-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +Ensure you are in project directory when you run this command. + + +## RELATED LINKS + +{{ Fill in the related links here }} + diff --git a/project.json b/project.json index 01f164c..3404217 100644 --- a/project.json +++ b/project.json @@ -1,7 +1,7 @@ { "ProjectName": "ModuleTools", "Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.", - "Version": "1.6.0", + "Version": "1.7.0", "copyResourcesToModuleRoot": false, "Manifest": { "Author": "Manjunath Beli", diff --git a/src/public/GetMTProjectInfo.ps1 b/src/public/GetMTProjectInfo.ps1 index 8964dbb..afb9aa2 100644 --- a/src/public/GetMTProjectInfo.ps1 +++ b/src/public/GetMTProjectInfo.ps1 @@ -1,36 +1,27 @@ -<# -.SYNOPSIS -Retrieves information about a project by reading data from a project.json file in ModuleTools project folder. - -.DESCRIPTION -The Get-MTProjectInfo function retrieves information about a project by reading data from a project.json file located in the current directory. Ensure you navigate to a module directory which has project.json in root directory. Most variables are already defined in output of this command which can be used in pester tests and other configs. - -.PARAMETER None -This function does not accept any parameters. - -.EXAMPLE -Get-MTProjectInfo -Retrieves project information from the project.json file in the current directory. Useful for debuggin and writing pester tests. - -.OUTPUTS -hastable with all project data. - -#> function Get-MTProjectInfo { - $Out = @{} - $ProjectRoot = Get-Location | Convert-Path - $Out['ProjecJSON'] = Join-Path -Path $ProjectRoot -ChildPath 'project.json' + [CmdletBinding()] + param( + [Parameter(Position = 0)] + [string]$Path = (Get-Location).Path + ) + $ProjectRoot = (Resolve-Path -LiteralPath $Path).Path + $ProjectJson = [System.IO.Path]::Join($ProjectRoot, 'project.json') - if (-not (Test-Path $Out.ProjecJSON)) { - Write-Error 'Not a Project folder, project.json not found' -ErrorAction Stop + if (-not (Test-Path -LiteralPath $projectJson)) { + throw "Not a project folder. project.json not found: $projectJson" } + + $jsonData = Get-Content -LiteralPath $projectJson -Raw | ConvertFrom-Json -AsHashtable + + $Out = @{} + $Out['ProjectJSON'] = Join-Path -Path $ProjectRoot -ChildPath 'project.json' - ## Metadata, Import all json data - $jsonData = Get-Content -Path $Out.ProjecJSON | ConvertFrom-Json -AsHashtable foreach ($key in $jsonData.Keys) { $Out[$key] = $jsonData[$key] } - $ProjectName = $Out.ProjectName + $Out.ProjectJson = $projectJson + $Out.PSTypeName = 'MTProjectInfo' + ## Folders $Out['ProjectRoot'] = $ProjectRoot $Out['PublicDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'public') @@ -43,6 +34,5 @@ function Get-MTProjectInfo { $Out['ModuleFilePSM1'] = [System.IO.Path]::Join($Out.OutputModuleDir, "$ProjectName.psm1") $Out['ManifestFilePSD1'] = [System.IO.Path]::Join($Out.OutputModuleDir, "$ProjectName.psd1") - $Output = [pscustomobject]$Out | Add-Member -TypeName MTProjectInfo -PassThru - return $Output + return [pscustomobject]$out } \ No newline at end of file diff --git a/src/public/InvokeMTBuild.ps1 b/src/public/InvokeMTBuild.ps1 index 0947c81..a5637e3 100644 --- a/src/public/InvokeMTBuild.ps1 +++ b/src/public/InvokeMTBuild.ps1 @@ -1,17 +1,3 @@ -<# -.SYNOPSIS - Invokes the process to build a module in ModuleTools format. - -.DESCRIPTION - This function is used to build a module, dist folder is cleaned up and whole module is build from scracth. copies all necessary resource files. - -.PARAMETER None - This function does not accept any parameters. - -.EXAMPLE - Invoke-MTBuild - Invokes the process to build a module. -#> function Invoke-MTBuild { [CmdletBinding()] param ( diff --git a/src/public/InvokeMTTests.ps1 b/src/public/InvokeMTTests.ps1 index 2d79351..65954d7 100644 --- a/src/public/InvokeMTTests.ps1 +++ b/src/public/InvokeMTTests.ps1 @@ -1,28 +1,3 @@ -<# -.SYNOPSIS -Runs Pester tests for using settings from project.json - -.DESCRIPTION -This function runs Pester tests using the specified configuration and settings in project.json. Place all your tests in "tests" folder - -.PARAMETER TagFilter -Array of tags to run, Provide the tag Pester should run - -.PARAMETER ExcludeTagFilter -Array of tags to exclude, Provide the tag Pester should exclude - -.EXAMPLE -Invoke-MTTest -Runs the Pester tests for the project. - -.EXAMPLE -Invoke-MTTest -TagFilter "unit","integrate" -Runs the Pester tests for the project, that has tag unit or integrate - -.EXAMPLE -Invoke-MTTest -ExcludeTagFilter "unit" -Runs the Pester tests for the project, excludes any test with tag unit -#> function Invoke-MTTest { [CmdletBinding()] param ( diff --git a/src/public/NewMTModule.ps1 b/src/public/NewMTModule.ps1 index 02a42b6..46df329 100644 --- a/src/public/NewMTModule.ps1 +++ b/src/public/NewMTModule.ps1 @@ -1,20 +1,3 @@ -<# -.SYNOPSIS -Create module scaffolding along with project.json file to easily build and manage modules - -.DESCRIPTION -This command creates folder structure and project.json file easily. Use this to quikcly setup a ModuleTools compatible module. - -.PARAMETER Path -Path where module will be created. Provide root folder path, module folder will be created as subdirectory. Path should be valid. - -.EXAMPLE -New-MTModule -Path c:\work -# Creates module inside c:\work folder - -.NOTES -The structure of the ModuleTools module is meticulously designed according to PowerShell best practices for module development. While some design decisions may seem unconventional, they are made to ensure that ModuleTools and the process of building modules remain straightforward and easy to manage. -#> function New-MTModule { [CmdletBinding(SupportsShouldProcess = $true)] param ( diff --git a/src/public/UpdateModVersion.ps1 b/src/public/UpdateModVersion.ps1 index 01eca5a..d0a0817 100644 --- a/src/public/UpdateModVersion.ps1 +++ b/src/public/UpdateModVersion.ps1 @@ -1,28 +1,3 @@ -<# -.SYNOPSIS -Updates the version number of a module in project.json file. Uses [semver] object type. - -.DESCRIPTION -This script updates the version number of a PowerShell module by modifying the project.json file, which gets written into module manifest file (.psd1). [semver] is supported only powershell 7 and above. -It increments the version number based on the specified version part (Major, Minor, Patch). Can also attach preview/stable release to Release property of - -.PARAMETER Label -The part of the version number to increment (Major, Minor, Patch). Default is patch. - -.PARAMETER PreviewRelease -Use this to use semantic version and attach release name as 'preview' which is supported by PowerShell gallery, to remove it use stable release parameter - -.EXAMPLE -Update-MTModuleVersion -Label Major -Updates the Major version part of the module. Version 2.1.3 will become 3.1.3 - -.EXAMPLE -Update-MTModuleVersion -Updates the Patch version part of the module. Version 2.1.3 will become 2.1.4 - -.NOTES -Ensure you are in project directory when you run this command. -#> function Update-MTModuleVersion { [CmdletBinding(SupportsShouldProcess = $true)] param( @@ -34,7 +9,7 @@ function Update-MTModuleVersion { Write-Verbose 'Running Version Update' $data = Get-MTProjectInfo - $jsonContent = Get-Content -Path $data.ProjecJSON | ConvertFrom-Json + $jsonContent = Get-Content -Path $data.ProjectJSON | ConvertFrom-Json [semver]$CurrentVersion = $jsonContent.Version $Major = $CurrentVersion.Major @@ -69,5 +44,5 @@ function Update-MTModuleVersion { $newJsonContent = $jsonContent | ConvertTo-Json # Write the updated JSON back to the file - $newJsonContent | Set-Content -Path $data.ProjecJSON + $newJsonContent | Set-Content -Path $data.ProjectJSON } \ No newline at end of file From 62706123bcfd514dd2265e3f47edf5ced18d2f8e Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Thu, 19 Mar 2026 13:04:43 -0500 Subject: [PATCH 14/18] install PlatyPS during github action --- .github/workflows/Tests.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index d34b5ad..8817414 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -20,8 +20,10 @@ jobs: - name: 📥 Checkout uses: actions/checkout@v4 - - name: 📦 Install ModuleTools module form PSGallery - run: Install-PSResource -Repository PSGallery -Name ModuleTools -TrustRepository + - name: 📦 Install required modules from PSGallery + run: | + Install-PSResource -Repository PSGallery -Name ModuleTools -TrustRepository + Install-PSResource -Repository PSGallery -Name Microsoft.PowerShell.PlatyPS -TrustRepository - name: 🏗️ Build Module run: Invoke-MTBuild -Verbose @@ -36,4 +38,4 @@ jobs: $Report = New-MDHeader -Text "Output Files 📁" -Level 2 $Report += Get-ChildItem -Path ./dist -Recurse | Select-Object Name, Directory | New-MDTable echo "$Report" >> $env:GITHUB_STEP_SUMMARY - echo "$Report" \ No newline at end of file + echo "$Report" From 62552cd0d5139a1658303a3fd9e14b6720075221 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Thu, 19 Mar 2026 13:05:18 -0500 Subject: [PATCH 15/18] install PlatyPS during github action --- .github/workflows/Publish.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Publish.yml b/.github/workflows/Publish.yml index c6ae27e..49305bc 100644 --- a/.github/workflows/Publish.yml +++ b/.github/workflows/Publish.yml @@ -3,7 +3,7 @@ name: Publish Module on: push: tags: - - '*' + - "*" workflow_dispatch: @@ -18,8 +18,10 @@ jobs: - name: 📥 Checkout uses: actions/checkout@v4 - - name: 📦 Install ModuleTools module form PSGallery - run: Install-PSResource -Repository PSGallery -Name ModuleTools -TrustRepository + - name: 📦 Install required modules from PSGallery + run: | + Install-PSResource -Repository PSGallery -Name ModuleTools -TrustRepository + Install-PSResource -Repository PSGallery -Name Microsoft.PowerShell.PlatyPS -TrustRepository - name: 🏗️ Build Module run: Invoke-MTBuild -Verbose @@ -45,4 +47,4 @@ jobs: exit 1 # Fail the workflow on error } env: - ApiKey: ${{ secrets.PSGALLERY_API }} \ No newline at end of file + ApiKey: ${{ secrets.PSGALLERY_API }} From f618ef9a37f3da8022d7c0f2539b898777d1019c Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Thu, 19 Mar 2026 14:43:21 -0500 Subject: [PATCH 16/18] bug fix in ProjectName --- docs/ModuleTools/Invoke-MTBuild.md | 6 ++---- project.json | 2 +- src/public/GetMTProjectInfo.ps1 | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/ModuleTools/Invoke-MTBuild.md b/docs/ModuleTools/Invoke-MTBuild.md index 322677f..b2903bf 100644 --- a/docs/ModuleTools/Invoke-MTBuild.md +++ b/docs/ModuleTools/Invoke-MTBuild.md @@ -35,15 +35,13 @@ copies all necessary resource files. ## EXAMPLES -### EXAMPLE 1 +### EXAMPLE 1: Builds module from the project files. Invoke-MTBuild -Builds module from the project files. -### EXAMPLE 2 +### EXAMPLE 2: Builds module and outputs verbose details during entire workflow. Invoke-MTBuild -Verbose -Builds module and outputs verbose details during entire workflow. ## PARAMETERS diff --git a/project.json b/project.json index 3404217..972a2aa 100644 --- a/project.json +++ b/project.json @@ -1,7 +1,7 @@ { "ProjectName": "ModuleTools", "Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.", - "Version": "1.7.0", + "Version": "1.7.1", "copyResourcesToModuleRoot": false, "Manifest": { "Author": "Manjunath Beli", diff --git a/src/public/GetMTProjectInfo.ps1 b/src/public/GetMTProjectInfo.ps1 index afb9aa2..19783ca 100644 --- a/src/public/GetMTProjectInfo.ps1 +++ b/src/public/GetMTProjectInfo.ps1 @@ -14,13 +14,14 @@ function Get-MTProjectInfo { $jsonData = Get-Content -LiteralPath $projectJson -Raw | ConvertFrom-Json -AsHashtable $Out = @{} - $Out['ProjectJSON'] = Join-Path -Path $ProjectRoot -ChildPath 'project.json' + $Out['ProjectJSON'] = $ProjectJson foreach ($key in $jsonData.Keys) { $Out[$key] = $jsonData[$key] } $Out.ProjectJson = $projectJson $Out.PSTypeName = 'MTProjectInfo' + $ProjectName = $jsonData.ProjectName ## Folders $Out['ProjectRoot'] = $ProjectRoot From 5ebf639ece00656ab969d0ad64924cf1170d8d81 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Fri, 1 May 2026 13:05:17 -0500 Subject: [PATCH 17/18] support dll --- CHANGELOG.md | 4 ++++ README.md | 6 ++++++ project.json | 2 +- src/private/BuildManifest.ps1 | 23 +++++++++++++++-------- src/private/CopyLib.ps1 | 8 ++++++++ src/public/GetMTProjectInfo.ps1 | 1 + src/public/InvokeMTBuild.ps1 | 1 + 7 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 src/private/CopyLib.ps1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 613a940..a47e6c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## [1.8.0] - 2025-05-01 + +- Added support for assembly files (dll) + ## [1.3.0] - 2025-09-23 - Added support for `ps1xml1` format data. Place it in resources folder with `Name.format.ps1xml` to be automatically added as format file and imported in module manifest diff --git a/README.md b/README.md index 09e7468..3228775 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ All the Module files should be in inside `src` folder │ └──  New-PublicFunction.ps1 ├──  resources │ └──  some-config.json +├──  lib +│ └── Some-assembly.dll └──  classes └──  Person.classes.ps1 └──  Person.enums.ps1 @@ -84,6 +86,10 @@ Run `New-MTModule` to generate the scaffolding; this will also create the `proje - All functions in the `private` folder are accessible internally within the module but are not exposed outside the module. - All `ps1` files in `classes` folder contains classes and enums, that are processed and placed in topmost of generated `psm1` files - Contents of the `src/resources` folder will be handled based on setting `copyResourcesToModuleRoot` +- +#### Lib Folder + +The `lib` folder within the `src` directory is intended for libraries and assempblies (dll files). When there is a library folder with dll files, it will be copied to module output dir and all dll are appended in module manifest as Required Assemblies. #### Resources Folder diff --git a/project.json b/project.json index 972a2aa..eefdc81 100644 --- a/project.json +++ b/project.json @@ -1,7 +1,7 @@ { "ProjectName": "ModuleTools", "Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.", - "Version": "1.7.1", + "Version": "1.8.0", "copyResourcesToModuleRoot": false, "Manifest": { "Author": "Manjunath Beli", diff --git a/src/private/BuildManifest.ps1 b/src/private/BuildManifest.ps1 index fd3b1ca..72fd0d2 100644 --- a/src/private/BuildManifest.ps1 +++ b/src/private/BuildManifest.ps1 @@ -32,17 +32,24 @@ function Build-Manifest { } } + ## load assemblies from lib (if any) + $RequiredAssemblies = @() + Get-ChildItem -Path $data.LibDir -File -Filter '*.dll' -ErrorAction SilentlyContinue | ForEach-Object { + $RequiredAssemblies += [System.IO.Path]::Join('.', 'lib', $_.Name) + } + $ManfiestAllowedParams = (Get-Command New-ModuleManifest).Parameters.Keys $sv = [semver]$data.Version $ParmsManifest = @{ - Path = $data.ManifestFilePSD1 - Description = $data.Description - FunctionsToExport = $functionToExport - AliasesToExport = $aliasToExport - RootModule = "$($data.ProjectName).psm1" - ModuleVersion = [version]$sv - FormatsToProcess = $FormatsToProcess - TypesToProcess = $TypesToProcess + Path = $data.ManifestFilePSD1 + Description = $data.Description + FunctionsToExport = $functionToExport + AliasesToExport = $aliasToExport + RootModule = "$($data.ProjectName).psm1" + ModuleVersion = [version]$sv + FormatsToProcess = $FormatsToProcess + TypesToProcess = $TypesToProcess + RequiredAssemblies = $RequiredAssemblies } ## Release lable diff --git a/src/private/CopyLib.ps1 b/src/private/CopyLib.ps1 new file mode 100644 index 0000000..b68e32b --- /dev/null +++ b/src/private/CopyLib.ps1 @@ -0,0 +1,8 @@ +function Copy-LibFolder { + $data = Get-MTProjectInfo + $libFolder = $data.LibDir + if (Test-Path $libFolder -ErrorAction SilentlyContinue) { + Write-Verbose 'Found lib folder, copying content to module' + Copy-Item -Path $libFolder -Destination ($data.OutputModuleDir) -Recurse -Force -ErrorAction Stop + } +} \ No newline at end of file diff --git a/src/public/GetMTProjectInfo.ps1 b/src/public/GetMTProjectInfo.ps1 index 19783ca..6862641 100644 --- a/src/public/GetMTProjectInfo.ps1 +++ b/src/public/GetMTProjectInfo.ps1 @@ -29,6 +29,7 @@ function Get-MTProjectInfo { $Out['PrivateDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'private') $Out['ClassesDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'classes') $Out['ResourcesDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'resources') + $Out['LibDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'lib') $Out['DocsDir'] = [System.IO.Path]::Join($ProjectRoot, 'docs') $Out['OutputDir'] = [System.IO.Path]::Join($ProjectRoot, 'dist') $Out['OutputModuleDir'] = [System.IO.Path]::Join($Out.OutputDir, $ProjectName) diff --git a/src/public/InvokeMTBuild.ps1 b/src/public/InvokeMTBuild.ps1 index a5637e3..62cbc4d 100644 --- a/src/public/InvokeMTBuild.ps1 +++ b/src/public/InvokeMTBuild.ps1 @@ -8,4 +8,5 @@ function Invoke-MTBuild { Build-Manifest Build-Help Copy-ProjectResource + Copy-LibFolder } \ No newline at end of file From 7cd780098dabefb77ec634b71d5e77e73ee9ee74 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Sat, 6 Jun 2026 21:20:14 -0500 Subject: [PATCH 18/18] minimum version required is 7.3 --- project.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project.json b/project.json index eefdc81..a60df32 100644 --- a/project.json +++ b/project.json @@ -1,11 +1,11 @@ { "ProjectName": "ModuleTools", "Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.", - "Version": "1.8.0", + "Version": "1.8.1", "copyResourcesToModuleRoot": false, "Manifest": { "Author": "Manjunath Beli", - "PowerShellHostVersion": "7.4", + "PowerShellHostVersion": "7.3", "GUID": "d1595b4a-a79f-4440-94f0-3196f4d29c41", "Tags": [], "ProjectUri": "https://github.com/belibug/ModuleTools"