Skip to content

Commit 5ebf639

Browse files
committed
support dll
1 parent f618ef9 commit 5ebf639

7 files changed

Lines changed: 36 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.8.0] - 2025-05-01
6+
7+
- Added support for assembly files (dll)
8+
59
## [1.3.0] - 2025-09-23
610

711
- 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

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ All the Module files should be in inside `src` folder
4545
│ └──  New-PublicFunction.ps1
4646
├──  resources
4747
│ └──  some-config.json
48+
├──  lib
49+
│ └── Some-assembly.dll
4850
└──  classes
4951
└──  Person.classes.ps1
5052
└──  Person.enums.ps1
@@ -84,6 +86,10 @@ Run `New-MTModule` to generate the scaffolding; this will also create the `proje
8486
- All functions in the `private` folder are accessible internally within the module but are not exposed outside the module.
8587
- All `ps1` files in `classes` folder contains classes and enums, that are processed and placed in topmost of generated `psm1` files
8688
- Contents of the `src/resources` folder will be handled based on setting `copyResourcesToModuleRoot`
89+
-
90+
#### Lib Folder
91+
92+
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.
8793

8894
#### Resources Folder
8995

project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ProjectName": "ModuleTools",
33
"Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.",
4-
"Version": "1.7.1",
4+
"Version": "1.8.0",
55
"copyResourcesToModuleRoot": false,
66
"Manifest": {
77
"Author": "Manjunath Beli",

src/private/BuildManifest.ps1

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,24 @@ function Build-Manifest {
3232
}
3333
}
3434

35+
## load assemblies from lib (if any)
36+
$RequiredAssemblies = @()
37+
Get-ChildItem -Path $data.LibDir -File -Filter '*.dll' -ErrorAction SilentlyContinue | ForEach-Object {
38+
$RequiredAssemblies += [System.IO.Path]::Join('.', 'lib', $_.Name)
39+
}
40+
3541
$ManfiestAllowedParams = (Get-Command New-ModuleManifest).Parameters.Keys
3642
$sv = [semver]$data.Version
3743
$ParmsManifest = @{
38-
Path = $data.ManifestFilePSD1
39-
Description = $data.Description
40-
FunctionsToExport = $functionToExport
41-
AliasesToExport = $aliasToExport
42-
RootModule = "$($data.ProjectName).psm1"
43-
ModuleVersion = [version]$sv
44-
FormatsToProcess = $FormatsToProcess
45-
TypesToProcess = $TypesToProcess
44+
Path = $data.ManifestFilePSD1
45+
Description = $data.Description
46+
FunctionsToExport = $functionToExport
47+
AliasesToExport = $aliasToExport
48+
RootModule = "$($data.ProjectName).psm1"
49+
ModuleVersion = [version]$sv
50+
FormatsToProcess = $FormatsToProcess
51+
TypesToProcess = $TypesToProcess
52+
RequiredAssemblies = $RequiredAssemblies
4653
}
4754

4855
## Release lable

src/private/CopyLib.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function Copy-LibFolder {
2+
$data = Get-MTProjectInfo
3+
$libFolder = $data.LibDir
4+
if (Test-Path $libFolder -ErrorAction SilentlyContinue) {
5+
Write-Verbose 'Found lib folder, copying content to module'
6+
Copy-Item -Path $libFolder -Destination ($data.OutputModuleDir) -Recurse -Force -ErrorAction Stop
7+
}
8+
}

src/public/GetMTProjectInfo.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function Get-MTProjectInfo {
2929
$Out['PrivateDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'private')
3030
$Out['ClassesDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'classes')
3131
$Out['ResourcesDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'resources')
32+
$Out['LibDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'lib')
3233
$Out['DocsDir'] = [System.IO.Path]::Join($ProjectRoot, 'docs')
3334
$Out['OutputDir'] = [System.IO.Path]::Join($ProjectRoot, 'dist')
3435
$Out['OutputModuleDir'] = [System.IO.Path]::Join($Out.OutputDir, $ProjectName)

src/public/InvokeMTBuild.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ function Invoke-MTBuild {
88
Build-Manifest
99
Build-Help
1010
Copy-ProjectResource
11+
Copy-LibFolder
1112
}

0 commit comments

Comments
 (0)