forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathARMSyncVersion.ps1
39 lines (34 loc) · 1.55 KB
/
ARMSyncVersion.ps1
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
[CmdletBinding()]
Param(
[Parameter(Mandatory=$False, Position=0)]
[String]$Folder
)
# Function to sync assembly version with module version
function SyncVersion([string]$FilePath)
{
$FolderPath = [System.IO.Path]::GetDirectoryName($FilePath)
Write-Output "Folder Path: $FolderPath"
$matches = ([regex]::matches((Get-Content $FilePath), "ModuleVersion = '([\d\.]+)'"))
$packageVersion = $matches.Groups[1].Value
Write-Output "Updating AssemblyInfo.cs inside of $FilePath to $packageVersion"
$assemblyInfos = Get-ChildItem -Path $FolderPath -Filter AssemblyInfo.cs -Recurse
ForEach ($assemblyInfo in $assemblyInfos)
{
$content = Get-Content $assemblyInfo.FullName
$content = $content -replace "\[assembly: AssemblyVersion\([\w\`"\.]+\)\]", "[assembly: AssemblyVersion(`"$packageVersion`")]"
$content = $content -replace "\[assembly: AssemblyFileVersion\([\w\`"\.]+\)\]", "[assembly: AssemblyFileVersion(`"$packageVersion`")]"
Write-Output "Updating assembly version in " $assemblyInfo.FullName
Set-Content -Path $assemblyInfo.FullName -Value $content -Encoding UTF8
}
#$content = $content.Replace("ModuleVersion = '$packageVersion'", "ModuleVersion = '$version'")
#Set-Content -path $FilePath -value $content
}
if (!$Folder)
{
$Folder = "$PSScriptRoot\..\src\ResourceManager"
}
$modules = Get-ChildItem -Path $Folder -Filter *.psd1 -Recurse -Exclude *.dll-help.psd1 | Where {!$_.Directory.FullName.Contains("Test\")}
ForEach ($module in $modules)
{
SyncVersion $module.FullName
}