-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
64 lines (50 loc) · 2.12 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
Param(
[string]$buildNumber = "0",
[string]$preRelease = "beta"
)
gci .\src -Recurse "packages.config" |% {
"Restoring " + $_.FullName
.\src\.nuget\nuget.exe install $_.FullName -o .\src\packages
}
Import-Module .\src\packages\psake.4.9.0\tools\psake\psake.psm1
# Thanks to Gian Maria https://www.codewrecks.com/post/general/find-msbuild-location-in-powershell/
# -------------------------------------------------------------------------------------------------
function Get-LatestMsbuildLocation
{
Param
(
[bool] $allowPreviewVersions = $false
)
if ($allowPreviewVersions) {
$latestVsInstallationInfo = Get-VSSetupInstance -All -Prerelease | Sort-Object -Property InstallationVersion -Descending | Select-Object -First 1
} else {
$latestVsInstallationInfo = Get-VSSetupInstance -All | Sort-Object -Property InstallationVersion -Descending | Select-Object -First 1
}
Write-Host "Latest version installed is $($latestVsInstallationInfo.InstallationVersion)"
if ($latestVsInstallationInfo.InstallationVersion -like "15.*") {
$msbuildLocation = "$($latestVsInstallationInfo.InstallationPath)\MSBuild\15.0\Bin\msbuild.exe"
Write-Host "Located msbuild for Visual Studio 2017 in $msbuildLocation"
} else {
$msbuildLocation = "$($latestVsInstallationInfo.InstallationPath)\MSBuild\Current\Bin\msbuild.exe"
Write-Host "Located msbuild in $msbuildLocation"
}
return $msbuildLocation
}
# -------------------------------------------------------------------------------------------------
$msBuildLocation = Get-LatestMsbuildLocation
if(Test-Path Env:\APPVEYOR_BUILD_NUMBER){
$buildNumber = [int]$Env:APPVEYOR_BUILD_NUMBER
Write-Host "Using APPVEYOR_BUILD_NUMBER"
$task = "appVeyor"
}
if(Test-Path env:BuildRunner) {
$buildRunner = Get-Content env:BuildRunner
if($buildRunner -eq "myget") {
$buildNumber = [int]$Env:BuildCounter
Write-Host "Using MYGET_BUILD_NUMBER"
$task = "myGet"
}
}
"Build number $buildNumber"
Invoke-Psake .\default.ps1 $task -properties @{ buildNumber=$buildNumber; preRelease=$preRelease; msbuild=$msBuildLocation }
Remove-Module psake