forked from OpenLiveWriter/OpenLiveWriter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
109 lines (87 loc) · 2.85 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Cause powershell to fail on errors rather than keep going
$ErrorActionPreference = "Stop";
@"
=======================================================
Checking solution exists
=======================================================
"@
$solutionFile = "$PSSCRIPTROOT\src\managed\writer.sln"
if (-Not (Test-Path "$solutionFile" -PathType Leaf))
{
"Unable to find solution file at $solutionFile"
exit 100
}
"Solution found at '$solutionFile'"
@"
=======================================================
Fetching MSBuild location
=======================================================
"@
# Install module to allow us to find MSBuild
# See https://github.com/Microsoft/vssetup.powershell
Install-Module VSSetup -Scope CurrentUser
$visualStudioLocation = (Get-VSSetupInstance `
| Select-VSSetupInstance -Version '[15.0,16.0)' -Latest).InstallationPath
$msBuildExe = $visualStudioLocation + "\MSBuild\15.0\Bin\msbuild.exe"
IF (-Not (Test-Path -LiteralPath "$msBuildExe" -PathType Leaf))
{
"MSBuild not found at '$msBuildExe'"
"In order to build OpenLiveWriter either Visual Studio 2017 (any edition) or Build "
"Tools for Visual Studio 2017 must be installed."
"These can be downloadd from https://visualstudio.microsoft.com/downloads/"
exit 101
}
"MSBuild.exe found at: '$msBuildExe'"
@"
=======================================================
Ensureing nuget.exe exists
=======================================================
"@
$nugetPath = "$env:LocalAppData\NuGet"
$nugetExe = "$nugetPath\NuGet.exe"
if (-Not (Test-Path -LiteralPath "$nugetExe" -PathType Leaf))
{
if (-Not (Test-Path -LiteralPath "$nugetPath" -PathType Container))
{
"Creating Directory '$nugetPath'"
New-Item "$nugetPath" -Type Directory
}
"Downloading nuget.exe"
Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' -OutFile "$nugetExe"
}
"Nuget.exe found at: '$nugetExe'"
@"
=======================================================
Ensure nuget packages exist
=======================================================
"@
$packageFolder = "$PSSCRIPTROOT\src\managed\packages"
if (Test-Path -LiteralPath $packageFolder)
{
"Packages found at '$packageFolder'"
}
else
{
"Running nuget restore"
& $nugetExe restore $solutionFile
}
@"
=======================================================
Check build type
=======================================================
"@
if (-Not (Test-Path env:OLW_CONFIG))
{
"Environment variable OWL_CONFIG not set, setting to 'Debug'"
$env:OLW_CONFIG = 'Debug'
}
"Using build '$env:OLW_CONFIG'"
@"
=======================================================
Starting build
=======================================================
"@
Get-Date
$buildCommand = "`"$msBuildExe`" $solutionFile /nologo /maxcpucount /verbosity:minimal /p:Configuration=$env:OLW_CONFIG $ARGS"
"Running build command '$buildCommand'"
Invoke-Expression "& $buildCommand"