-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathBuildManifest.ps1
More file actions
69 lines (61 loc) · 2.35 KB
/
BuildManifest.ps1
File metadata and controls
69 lines (61 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function Build-Manifest {
Write-Verbose 'Building psd1 data file Manifest'
$data = Get-MTProjectInfo
## TODO - DO schema check
$PubFunctionFiles = Get-ChildItem -Path $data.PublicDir -Filter *.ps1
$functionToExport = @()
$aliasToExport = @()
$PubFunctionFiles.FullName | ForEach-Object {
$functionToExport += Get-FunctionNameFromFile -filePath $_
$aliasToExport += Get-AliasInFunctionFromFile -filePath $_
}
## Import Format.ps1xml (if any)
$FormatsToProcess = @()
Get-ChildItem -Path $data.ResourcesDir -File -Filter '*Format.ps1xml' -ErrorAction SilentlyContinue | ForEach-Object {
if ($data.copyResourcesToModuleRoot) {
$FormatsToProcess += $_.Name
} else {
$FormatsToProcess += Join-Path -Path 'resources' -ChildPath $_.Name
}
}
## Import Types.ps1xml1 (if any)
$TypesToProcess = @()
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 = @{
Path = $data.ManifestFilePSD1
Description = $data.Description
FunctionsToExport = $functionToExport
AliasesToExport = $aliasToExport
RootModule = "$($data.ProjectName).psm1"
ModuleVersion = [version]$sv
FormatsToProcess = $FormatsToProcess
TypesToProcess = $TypesToProcess
}
## Release lable
if ($sv.PreReleaseLabel) {
$ParmsManifest['Prerelease'] = $sv.PreReleaseLabel
}
# Accept only valid Manifest Parameters
$data.Manifest.Keys | ForEach-Object {
if ( $ManfiestAllowedParams -contains $_) {
if ($data.Manifest.$_) {
$ParmsManifest.add($_, $data.Manifest.$_ )
}
} else {
Write-Warning "Unknown parameter $_ in Manifest"
}
}
try {
New-ModuleManifest @ParmsManifest -ErrorAction Stop
} catch {
'Failed to create Manifest: {0}' -f $_.Exception.Message | Write-Error -ErrorAction Stop
}
}