forked from versionone/VersionOne.Build.Common
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.ps1
80 lines (73 loc) · 2.13 KB
/
setup.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
73
74
75
76
77
78
79
80
param(
[alias("t")]
[string] $tasks = ''
)
function GetModulePath([string]$module){
$commonPath = @(Get-ChildItem -r -Path packages -filter $module | Sort-Object FullName -descending)
return $commonPath[0].FullName
}
function DownloadNuget(){
new-item (Get-Location).Path -name .nuget -type directory -force
$destination = (Get-Location).Path + '\.nuget\nuget.exe'
Write-Host "Destination for nuget=" $destination
#This will insure the latest nuget.exe. Having a fixed version caused issue when tls changed
$latestNuget = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $latestNuget -OutFile $destination
}
function DownloadAndImportModules(){
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
.nuget\nuget.exe install psake -OutputDirectory packages -NoCache
.nuget\nuget.exe install psake-tools -Source http://www.myget.org/F/versionone/api/v2/ -OutputDirectory packages -NoCache
}
function CopyPsakeToolsToRoot(){
$toolsPath = GetModulePath "psake-tools.ps1"
Copy-Item -Path $toolsPath -Destination (Get-Location).Path -Force
$helpersPath = GetModulePath "psake-tools-helpers.ps1"
Copy-Item -Path $helpersPath -Destination (Get-Location).Path -Force
}
function ImportPsake(){
$psakePath = GetModulePath "psake.psm1"
Import-Module $psakePath
}
try{
DownloadNuget
Write-Host "DownloadNuget ran"
}
Catch {
throw "DownloadNuget failed."
}
try{
DownloadAndImportModules
Write-Host "DownloadAndImportModules ran"
}
Catch {
throw "DownloadAndImportModules failed."
}
try{
ImportPsake
Write-Host "ImportPsake ran"
}
Catch {
throw "ImportPsake failed."
}
try{
CopyPsakeToolsToRoot
Write-Host "CopyPsakeToolsToRoot ran"
}
Catch {
throw "CopyPsakeToolsToRoot failed."
}
try{
Invoke-psake psake-tools.ps1 ($tasks.Split(',').Trim())
Write-Host "invoke psake ran"
}
Catch {
throw " Invoke-psake psake-tools.ps with args failed."
}
Finally {
if ($psake.build_success -eq $false) {
throw "problem with psak.build_success"
}
}