-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
64 lines (59 loc) · 1.97 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
62
63
64
$Global:ErrorActionPreference = 'Stop'
$Global:VerbosePreference = 'SilentlyContinue'
### Prepare NuGet / PSGallery
if (!(Get-PackageProvider | Where-Object { $_.Name -eq 'NuGet' })) {
"Installing NuGet"
Install-PackageProvider -Name NuGet -force | Out-Null
}
"Preparing PSGallery repository"
Import-PackageProvider -Name NuGet -force | Out-Null
if ((Get-PSRepository -Name PSGallery).InstallationPolicy -ne 'Trusted') {
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
}
### Install PSDepend
$psDepend = Get-Module -Name PSDepend -ListAvailable
if (!$psDepend) {
"Installing PSDepend"
Install-Module PSDepend
}
else {
"Using PSDepend $($psDepend.Version)"
}
### Install build dependencies if required
$dependencies = Get-Dependency -Path "$PSScriptRoot\build.depend.psd1"
if ($dependencies) {
"Build dependencies: $($dependencies.DependencyName -join ', ')"
$needInvokePSDepend = $false
}
else {
"No build dependencies"
$needInvokePSDepend = $true
}
foreach ($dep in $dependencies) {
$moduleVersions = Get-Module -Name $dep.DependencyName -ListAvailable | `
Select-Object -ExpandProperty Version | `
Foreach-Object { "$($_.Major).$($_.Minor).$($_.Build)" }
if (!($moduleVersions -contains $dep.Version)) {
$needInvokePSDepend = $true
break
}
}
if ($needInvokePSDepend) {
"Installing build dependencies"
Invoke-PSDepend -Path "$PSScriptRoot\build.depend.psd1" -Force -Verbose
}
else {
"Dependencies don't need updating"
}
### Install project dependencies
$projectRequirementsFile = "$PSScriptRoot\..\requirements.psd1"
if (Test-Path -Path $projectRequirementsFile) {
"Installing project dependencies"
Invoke-PSDepend -Path $projectRequirementsFile -Force
}
### Run psake
"Setting build environment to $PSScriptRoot\.."
Set-BuildEnvironment -Path "$PSScriptRoot\.." -Force
"Starting psake build"
Invoke-psake -buildFile "$PSScriptRoot\psake.ps1" -nologo
exit ( [int]( -not $psake.build_success ) )