-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy path_init.ps1
72 lines (61 loc) · 2.63 KB
/
_init.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
65
66
67
68
69
70
71
72
# This file is a bootstrapper for the real build file. It's purpose is as follows:
#
# 1. Define some top-level fubctions (build, clean, rebuild) that can be used to kick off the build from the command-line.
# 2. Download nuget.exe and then obtain some NuGet packages that the real build script relies on.
# 3. Import the RedGate.Build module to make available some convenient build cmdlets.
$VerbosePreference = 'Continue' # Want useful output in our build log files.
$ProgressPreference = 'SilentlyContinue' # Progress logging slows down TeamCity when downloading files with Invoke-WebRequest.
$ErrorActionPreference = 'Stop' # Abort quickly on error.
function global:Build
{
[CmdletBinding()]
param(
[string[]] $Task = @('Default'),
[ValidateSet('Release', 'Debug')]
[string] $Configuration = 'Release'
)
Push-Location $PsScriptRoot -Verbose
try
{
# Obtain nuget.exe
$NuGetVersion = [version] '4.9.3'
$NuGetPath = '.\nuget.exe'
if (-not (Test-Path $NuGetPath) -or (Get-Item $NuGetPath).VersionInfo.ProductVersion -ne $NuGetVersion)
{
$NuGetUrl = "https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/nuget.exe"
Write-Host "Downloading $NuGetUrl"
Invoke-WebRequest $NuGetUrl -OutFile $NuGetPath
}
# Restore the 'build-level' nuget packages into .build/packages if necessary.
$NuGetConfigXml = [xml](Get-Content 'packages.config')
$NuGetConfigXml.packages.package | ForEach-Object {
& $NuGetPath install $_.id `
-Version $_.version `
-OutputDirectory 'packages' `
-ExcludeVersion `
-PackageSaveMode nuspec
}
# Import the RedGate.Build module.
Import-Module '.\packages\RedGate.Build\tools\RedGate.Build.psm1' -Force
# Call the actual build script.
& '.\packages\Invoke-Build\tools\Invoke-Build.ps1' -File .\build.ps1 -Task $Task -Configuration $Configuration
}
finally
{
Pop-Location
}
}
function global:Clean
{
Build -Task Clean
}
function global:Rebuild
{
[CmdletBinding()]
param([ValidateSet('Release', 'Debug')] [string] $Configuration = 'Release')
Build -Task Rebuild -Configuration $Configuration
}
Write-Host 'This is the XmlDoc2CmdletDoc repo. Here are the available commands:' -ForegroundColor Magenta
Write-Host " Build [-Task <task-list>] [-Configuration <Debug|Release>]" -ForegroundColor Green
Write-Host " Clean" -ForegroundColor Green
Write-Host " Rebuild [-Configuration <Debug|Release>]" -ForegroundColor Green