forked from emcifuntik/gtautil
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.ps1
59 lines (50 loc) · 2.13 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
Param (
[string]$build= "Release"
)
Install-Module VSSetup -Scope CurrentUser -Force
function Find-MSBuild
{
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
}
$MSBuild = Find-MSBuild
function Find-MSBuild
{
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
}
$MSBuild = Find-MSBuild
& "$MSBuild" -t:restore
& "$MSBuild" GTAUtil.sln /p:Configuration=$build