This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.ps1
61 lines (49 loc) · 2.02 KB
/
build.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
60
61
param([string]$Config = 'Test', # Test Or Prod
[boolean]$Clean = $true,
[string]$VersionMajor = "0",
[string]$VersionMinor = "7",
[string]$VersionPatch = "975"
)
# Use PowerShell Core
Set-Location $PSScriptRoot
Function setConfig($UseConfig){
$UseConfig = $UseConfig.ToLower()
$Content = Get-Content ".\vss-extension.$UseConfig.json" -Raw
$FullVersion = "$($VersionMajor).$($VersionMinor).$($VersionPatch)"
$Content = $Content.Replace('{FullVersion}', $FullVersion)
Set-Content ".\vss-extension.json" $Content
$tasks = Get-ChildItem -Filter "task.$UseConfig.json" -File -Recurse -Depth 1
foreach ($t in $tasks){
$NewName = ($t.FullName).Replace(".$($UseConfig)","")
$Content = Get-Content $t.FullName -Raw
$Content = $Content.Replace('"{VersionMajor}"', $VersionMajor)
$Content = $Content.Replace('"{VersionMinor}"', $VersionMinor)
$Content = $Content.Replace('"{VersionPatch}"', $VersionPatch)
Set-Content $NewName $Content
}
Return
}
Function DownloadModules($TaskFolder, $ModuleName){
$TaskModuleFolder = Join-Path $TaskFolder "\ps_modules"
$ModuleFolder = Join-Path $TaskModuleFolder $ModuleName
if (Test-Path -Path $ModuleFolder){
Remove-Item $ModuleFolder -Force -Recurse
}
New-Item -ItemType Directory $TaskModuleFolder -Force | Out-Null
Save-Module -Name $ModuleName -Path $TaskModuleFolder -Force -Confirm:$false -AllowPrerelease
Get-ChildItem $TaskModuleFolder\$ModuleName\*\* | % {
Move-Item -Path $_.FullName -Destination $TaskModuleFolder\$ModuleName\
}
}
setConfig $Config
$Folders = Get-ChildItem -Filter Deploy* -Directory
foreach ($TaskFolder in $Folders.name){
if ((!(Test-Path -Path (Join-Path $TaskFolder "\ps_modules\VstsTaskSDK"))) -or ($Clean)){
DownloadModules $TaskFolder "VstsTaskSDK"
}
if ((!(Test-Path -Path (Join-Path $TaskFolder "\ps_modules\azure.databricks.cicd.tools"))) -or ($Clean)){
DownloadModules $TaskFolder "azure.databricks.cicd.tools"
}
}
Remove-Item ./bin/*.* -Force -ErrorAction SilentlyContinue
&tfx extension create --manifest-globs vss-extension.json --output-path ./bin