-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.ps1
121 lines (95 loc) · 3.92 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
110
111
112
113
114
115
116
117
118
119
120
121
##
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
##
##
# Builds the source code and generates nuget packages. You can optionally just build the source code by opening individual solutions in Visual Studio.
##
param
(
# Show versions of all tools used
[switch]$showVersion,
# Build Code
[switch]$build,
# Generate NuPkg
[switch]$nuget,
# Do All the Above tasks together
[switch]$buildAll,
# Build the bkpctl Cli
[switch]$buildCli,
# Path to MSBuild if VS2017 is installed in non-conventional Location
[string]$MSBuildFullPath,
# Version of VS Installed
[ValidateSet('2017','2019')]
[string]$vsversion ="2017",
# Build configuration - Default is Debug
[ValidateSet('Debug', 'Release')]
[string]$Configuration = 'Debug'
);
# Include comman commands.
. "./common.ps1"
$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$NugetFullPath = join-path $PSScriptRoot "nuget.exe"
if ($MSBuildFullPath -eq "") {
$MSBuildFullPath = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
Write-Host "Auto detected MSBuild path: " $MSBuildFullPath
if ($MSBuildFullPath -eq "" -or $MSBuildFullPath -eq $null)
{
throw "Could not auto detect MSBuild path"
}
}
if (!(Test-Path $MSBuildFullPath)) {
throw "Unable to find MSBuild installed on this machine. Please install Visual Studio 2017 or if its installed at non-default location, provide the full path to msbuild using -MSBuildFullPath parameter."
}
$DisplayHelp = $true;
if ($showVersion) {
$DisplayHelp = $false;
Write-Host "Version of all tools:"
dotnet --info
Write-Host "MSBuild Version:"
& $MSBuildFullPath /version
}
if ($build -Or $buildAll) {
$DisplayHelp = $false;
# build all projects
Write-Host "Building Backup Explorer Code and Tests:"
Exec { dotnet build --packages .\packages backupExplorer.sln -c $Configuration }
# publish for nupkg generation
pushd src\BackupExplorer\Parser\
Exec { dotnet publish --no-build --framework netstandard2.0 -c $Configuration }
Exec { dotnet publish --no-build --framework net48 -c $Configuration }
popd
pushd src\BackupExplorer\RestServer\
Exec { dotnet publish --no-build -c $Configuration }
popd
xcopy .\src\backup-explorer-cli\* .\bin\backup-explorer-cli /E /C /I /Y
}
if ($nuget -Or $buildAll) {
$DisplayHelp = $false;
Write-Host "Generating Nuget Package:"
pushd nuprojs
# nuget restore
Exec { & $NugetFullPath restore -Verbosity detailed .nuget\packages.config -PackagesDirectory .\packages }
# generate nupkg
Exec { & $NugetFullPath pack Microsoft.ServiceFabric.ReliableCollectionBackup.Parser.nuspec -basepath ..\bin\ReliableCollectionBackupParser\netstandard2.0 -OutputDirectory ..\bin\ -properties NoWarn=NU5100,NU5128 }
popd
}
if ($buildCli -Or $buildAll) {
$DisplayHelp = $false;
Write-Host "Building Service Fabric Backup Explorer CLI bkpctl:"
pushd src
# Build bkpctl package
Exec { pip install -e backup-explorer-cli }
popd
}
if ($DisplayHelp) {
Write-Host "Following options are available :"
Write-Host "1. -build Builds the Code"
Write-Host "2. -buildAll Builds the Code and generate Nuget package"
Write-Host "3. -nuget Generate the nuget package"
Write-Host "4. -showVersion Displays versions of all tools"
Write-Host "5. -buildCli Builds the bkpctl CLI tool for viewing and editing Backups"
Write-Host "6. -vsversion User can specify the version of Visual Studio to use , VS 2017 by default."
Write-Host "7. -MSBuildFullPath User can specify where to look for MSBuild in case VS is installed in unusual Location"
Write-Host "8. -Configuration User can specify either to build in Debug or Release "
}