-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUpdateAssemblyInfo.ps1
59 lines (44 loc) · 2.11 KB
/
UpdateAssemblyInfo.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
55
56
57
58
59
If (-not (Test-Path Env:\TF_BUILD_BUILDURI))
{
Write-Host 'TF_BUILD_BUILDURI environment variable is not defined.';
Return;
}
$buildUri = [System.Uri](Get-Content Env:\TF_BUILD_BUILDURI)
$buildId = Split-Path -Leaf $buildUri.LocalPath
Function UpdateAssemblyInfoWithBuildNumber([string] $solutionAssemblyInfoFile)
{
$solutionAssemblyInfo = Get-Content $solutionAssemblyInfoFile
$updatedVersionInfo = $solutionAssemblyInfo -replace "Version\(`"(\d+)\.(\d+)\.(\d+)\.\d+`"\)\]`$", "Version(`"`$1`.`$2`.$buildId.0`")]"
$updatedVersionInfo | Out-File $solutionAssemblyInfoFile
}
Function UpdateMergeModuleScriptWithBuildNumber([string] $wixScriptFile)
{
$wixScript = New-Object -TypeName 'System.Xml.XmlDocument'
$wixScript.PreserveWhitespace = $true
$wixScript.Load($wixScriptFile)
$wixScript.Wix.Module.Version = $wixScript.Wix.Module.Version -replace "(\d+)\.(\d+)\.(\d+)", "`$1`.`$2`.$buildId"
$wixScript.Save($wixScriptFile)
}
Function UpdateSetupScriptWithBuildNumber([string] $wixScriptFile)
{
$wixScript = New-Object -TypeName 'System.Xml.XmlDocument'
$wixScript.PreserveWhitespace = $true
$wixScript.Load($wixScriptFile)
$wixScript.Wix.Product.Version = $wixScript.Wix.Product.Version -replace "(\d+)\.(\d+)\.(\d+)", "`$1`.`$2`.$buildId"
$wixScript.Save($wixScriptFile)
}
Function UpdateSqlProjectWithBuildNumber([string] $sqlProjectFile)
{
$sqlProject = Get-Content $sqlProjectFile
$sqlProject = $sqlProject -replace "\<DacVersion\>(\d+)\.(\d+)\.(\d+)\.(\d+)\<\/DacVersion\>", "<DacVersion>`$1`.`$2`.$buildId.`$4</DacVersion>"
Set-Content $sqlProjectFile -Value $sqlProject
}
Function UpdateNuSpecWithBuildNumber([string] $nuSpecFile)
{
$nuSpec = Get-Content $nuSpecFile
$nuSpec = $nuSpec -replace "\<version\>(\d+)\.(\d+)\.(\d+).(\d+)\<\/version\>", "<version>1.1.$buildId.0</version>"
Set-Content $nuSpecFile -Value $nuSpec
}
$currentDir = (Get-Location).Path
UpdateAssemblyInfoWithBuildNumber(Join-Path $currentDir "SolutionAssemblyInfo.cs")
UpdateNuSpecWithBuildNumber(Join-Path $currentDir "OctopusDeploy.Powershell\OctopusDeploy.Powershell.nuspec")