-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.ps1
More file actions
89 lines (71 loc) · 2.39 KB
/
build.ps1
File metadata and controls
89 lines (71 loc) · 2.39 KB
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
81
82
83
84
85
86
87
88
89
#Requires -RunAsAdministrator
Function Info($msg) {
Write-Host -ForegroundColor DarkGreen "`nINFO: $msg`n"
}
Function Error($msg) {
Write-Host `n`n
Write-Error $msg
exit 1
}
Function CheckReturnCodeOfPreviousCommand($msg) {
if(-Not $?) {
Error "${msg}. Error code: $LastExitCode"
}
}
Function FindMsBuild() {
$vswhereCommand = Get-Command -Name "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$msbuild = `
& $vswhereCommand `
-latest `
-requires Microsoft.Component.MSBuild `
-find MSBuild\**\Bin\MSBuild.exe `
| select-object -first 1
if(!$msbuild)
{
Error "Can't find MsBuild"
}
Info "MsBuild found: `n $msbuild"
return $msbuild
}
Function FindVcPkg() {
$vswhereCommand = Get-Command -Name "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$installationPath = & $vswhereCommand -prerelease -latest -property installationPath
return "$installationPath/VC/vcpkg/vcpkg.exe"
}
Function GetInstallerVersion() {
$gitCommand = Get-Command -Name git
try { $tag = & $gitCommand describe --exact-match --tags HEAD 2> $null } catch { }
if(-Not $?) {
Info "The commit is not tagged. Use 'v0.0' as a tag instead"
$tag = "v0.0"
}
return $tag.Substring(1)
}
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
$root = Resolve-Path $PSScriptRoot
$buildDir = "$root/build"
$installerVersion = GetInstallerVersion
$msbuild = FindMsBuild
$vcPkg = FindVcPkg
Info "InstallerVersion: '$installerVersion'"
Info "Integrate VcPkg"
& $vcPkg integrate install
Info "Build project"
& $msbuild `
/nologo `
/restore `
/verbosity:minimal `
/property:Configuration=Release `
/property:DebugType=None `
/property:InstallerVersion=$installerVersion `
$root/DOpusScriptingExtensions.sln
CheckReturnCodeOfPreviousCommand "build failed"
Info "Run tests"
cscript $root/src/test/test.js
CheckReturnCodeOfPreviousCommand "tests failed"
Info "Copy installer to the Publish directory and create zip archive"
New-Item -Force -ItemType "directory" $buildDir/Publish > $null
Copy-Item -Force -Path $buildDir/x64/Release/Installer/Installer.msi -Destination $buildDir/Publish/DOpusScriptingExtensions.msi > $null
Compress-Archive -Force -Path $buildDir/Publish/DOpusScriptingExtensions.msi -DestinationPath $buildDir/Publish/DOpusScriptingExtensions.msi.zip