forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommonIncrementVersion.ps1
54 lines (45 loc) · 2.27 KB
/
CommonIncrementVersion.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True, Position=0)]
[String]$Version,
[Parameter(Mandatory=$False, Position=1)]
[String]$Folder
)
function SetCommandsCommonVersion([string]$FilePath, [string]$Version)
{
$powershellCs = Join-Path $FilePath "Common\Commands.Common\AzurePowerShell.cs"
Write-Output "Updating File: $powershellCs"
$content = Get-Content $powershellCs
$content = $content -replace "public const string AssemblyVersion = `"([\d\.]+)`";", "public const string AssemblyVersion = `"$Version`";"
$content = $content -replace "public const string AssemblyFileVersion = `"([\d\.]+)`";", "public const string AssemblyFileVersion = `"$Version`";"
Set-Content -Path $powershellCs -Value $content -Encoding UTF8
}
function SetArmCommonVersion([string]$FilePath, [string]$Version)
{
$assemblyConfig = Join-Path $FilePath "ResourceManager\Common\Commands.ResourceManager.Common\Properties\AssemblyInfo.cs"
Write-Output "Updating File: $assemblyConfig"
$content = Get-Content $assemblyConfig
$content = $content -replace "\[assembly: AssemblyVersion\([\w\`"\.]+\)\]", "[assembly: AssemblyVersion(`"$Version`")]"
$content = $content -replace "\[assembly: AssemblyFileVersion\([\w\`"\.]+\)\]", "[assembly: AssemblyFileVersion(`"$Version`")]"
Set-Content -Path $assemblyConfig -Value $content -Encoding UTF8
}
function SetCommonAssemlbyVersions([string]$FilePath, [string]$Version)
{
$commonAssemblies = Join-Path $FilePath "Common"
$assemblyInfos = Get-ChildItem -Path $commonAssemblies -Filter AssemblyInfo.cs -Recurse
ForEach ($assemblyInfo in $assemblyInfos)
{
$content = Get-Content $assemblyInfo.FullName
$content = $content -replace "\[assembly: AssemblyVersion\([\w\`"\.]+\)\]", "[assembly: AssemblyVersion(`"$Version`")]"
$content = $content -replace "\[assembly: AssemblyFileVersion\([\w\`"\.]+\)\]", "[assembly: AssemblyFileVersion(`"$Version`")]"
Write-Output "Updating assembly version in " $assemblyInfo.FullName
Set-Content -Path $assemblyInfo.FullName -Value $content -Encoding UTF8
}
}
if (!$Folder)
{
$Folder = "$PSScriptRoot\..\src"
}
SetCommandsCommonVersion $Folder $Version
SetCommonAssemlbyVersions $Folder $Version
SetArmCommonVersion $Folder $Version