-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path_Build-RscSdk.ps1
85 lines (70 loc) · 2.14 KB
/
_Build-RscSdk.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
<#
.SYNOPSIS
Build the Rubrik Security Cloud SDK.
.DESCRIPTION
This script
- runs Clean-RscSdk.ps1 to remove any previous build artifacts.
- builds the Rubrik Security Cloud SDK and copies the output
to the Output/ directory.
- runs Test-RscSdk.ps1 to run the tests.
By default, the script will run the tests.
You can skip the tests by passing -NoTests.
By default, the script will build the Debug version of the SDK.
You can build the Release version by passing -Release.
Note that the Release build is copied to the Output.Release/ directory
instead of Output/.
#>
param(
[switch]$NoClean = $false,
[switch]$Release = $false,
[switch]$NoDocs = $false,
[switch]$NoTests = $false,
[switch]$CI = $false
)
# Change to the root of the repository
Set-Location $PSScriptRoot\..
if (-Not $NoClean) {
.\Utils\Clean-RscSdk.ps1
}
$OutputDir = ".\Output"
$ProjectDir = ".\RubrikSecurityCloud\RubrikSecurityCloud.PowerShell"
$ProjectOutputDir = "$ProjectDir\bin\Debug"
if ($Release) {
$OutputDir = ".\Output.Release"
$ProjectOutputDir = "$ProjectDir\bin\Release"
}
# Stop on error
$ErrorActionPreference = "Stop"
# Make sure we have dotnet
try {
$dotnetVersion = dotnet --version
Write-Host "dotnet version: $dotnetVersion"
} catch {
Write-Error "Failed to execute 'dotnet --version'. Please ensure .NET SDK is correctly installed and accessible."
exit 1
}
# Build the project
$buildCommand = if ($Release) {
"dotnet build --configuration Release /p:GeneratePSDocs=true $ProjectDir"
} elseif ($NoDocs) {
"dotnet build $ProjectDir"
} else {
"dotnet build /p:GeneratePSDocs=true $ProjectDir"
}
Invoke-Expression $buildCommand
if ($LASTEXITCODE -ne 0 ) {
Write-Error "dotnet build failed."
exit $LASTEXITCODE
}
# Copy the output to the output directory
Copy-Item -Recurse -Force $ProjectOutputDir $OutputDir
$helpXmlPath = "$OutputDir\net6.0\RubrikSecurityCloud.PowerShell.dll-Help.xml"
if (Test-Path $helpXmlPath) {
Copy-Item $helpXmlPath $OutputDir\net462\
} else {
Write-Warning "Documentation XML file not found. Skipping copy."
}
if (-not $NoTests) {
# Run the tests
.\Utils\Test-RscSdk.ps1 -CI:$CI
}