Skip to content

Commit b0fc028

Browse files
committed
Merge pull request #55 from cbadke/SynchVersion
Automatically apply version from dll to powershell module manifest
2 parents 454453e + 9d070eb commit b0fc028

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

MakeRelease.ps1

Lines changed: 5 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,11 @@ foreach ($file in $files)
4140
cp $PSScriptRoot\$file $targetDir\en-us
4241
}
4342

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

PSReadLine/PSReadLine.psd1

0 Bytes
Binary file not shown.

Update-ModuleManifest.ps1

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

0 commit comments

Comments
 (0)