-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
56 lines (40 loc) · 1.66 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
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[ValidateSet('Debug', 'Release')]
[string]
$Configuration = 'Debug',
[Parameter(Mandatory = $false)]
[ValidateSet('Build', 'Test', 'Docs')]
[string]
$Task = 'Build'
)
Import-Module "$PSScriptRoot/tools/helper.psm1" -Force
Write-Log "Validate and install missing prerequisites for building ..."
Install-Dotnet
$modulePath = Join-Path -Path $PSScriptRoot -ChildPath 'tools' -AdditionalChildPath 'Modules'
$requirements = Import-PowerShellDataFile -Path (Join-Path -Path $PSScriptRoot -ChildPath 'requirements-dev.psd1')
foreach ($req in $requirements.GetEnumerator()) {
$targetPath = Join-Path -Path $modulePath -ChildPath $req.Key
if (Test-Path -LiteralPath $targetPath) {
Import-Module -Name $targetPath -Force -ErrorAction Stop
continue
}
Write-Log "Installing build pre-req $($req.Key) as it is not installed"
New-Item -Path $targetPath -ItemType Directory | Out-Null
$webParams = @{
Uri = "https://www.powershellgallery.com/api/v2/package/$($req.Key)/$($req.Value)"
OutFile = Join-Path -Path $modulePath -ChildPath "$($req.Key).zip"
UseBasicParsing = $true
}
Invoke-WebRequest @webParams
Expand-Archive -Path $webParams.OutFile -DestinationPath $targetPath -Force
Remove-Item -LiteralPath $webParams.OutFile -Force
Import-Module -Name $targetPath -Force -ErrorAction Stop
}
$invokeBuildParams = @{
Task = @($Task)
File = Join-Path -Path $PSScriptRoot -ChildPath 'PoshJsonWebToken.build.ps1'
Configuration = $Configuration
}
Invoke-Build @invokeBuildParams