Skip to content

Commit 099c401

Browse files
committed
Automatically apply version from dll to powershell module manifest
1 parent 34f080e commit 099c401

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

MakeRelease.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ $files = @('Changes.txt',
2525
'PSReadline\PSReadline.psd1',
2626
'PSReadline\PSReadline.psm1',
2727
'PSReadline\PSReadline.format.ps1xml',
28-
'PSReadline\PSReadline.format.ps1xml',
2928
'PSReadline\bin\Release\PSReadline.dll')
3029

3130
foreach ($file in $files)
@@ -41,6 +40,10 @@ foreach ($file in $files)
4140
cp $PSScriptRoot\$file $targetDir\en-us
4241
}
4342

43+
$version = (Get-ChildItem $targetDir\PSReadline.dll).VersionInfo.FileVersion
44+
45+
Update-ModuleManifest $targetDir\PSReadline.psd1 $version
46+
4447
del $PSScriptRoot\PSReadline.zip -ea Ignore
4548
[System.IO.Compression.ZipFile]::CreateFromDirectory($targetDir, "$PSScriptRoot\PSReadline.zip")
4649

PSReadLine/PSReadLine.psd1

0 Bytes
Binary file not shown.

Update-ModuleManifest.ps1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
function Update-ModuleManifest {
3+
param (
4+
[Parameter(Mandatory=$TRUE)]
5+
[String] $FilePath,
6+
[Parameter(Mandatory=$TRUE)]
7+
[String] $Version
8+
)
9+
10+
if ((Test-Path $FilePath -PathType Leaf) -ne $TRUE) {
11+
Write-Error -Message ($FilePath + ' not found.') -Category InvalidArgument;
12+
exit 1;
13+
}
14+
15+
#normalize path
16+
$FilePath = (Resolve-Path $FilePath).Path;
17+
18+
$moduleVersionPattern = "ModuleVersion = '.*'";
19+
$newVersion = "ModuleVersion = '" + $Version + "'";
20+
21+
(Get-Content $FilePath) | % {$_ -replace $moduleVersionPattern, $newVersion} | Set-Content $FilePath;
22+
}

0 commit comments

Comments
 (0)