Skip to content

Commit ec3d0e5

Browse files
authored
Merge pull request #82 from dependency-check/develop
6.0.0.4 Release
2 parents f7ef113 + 778bb9e commit ec3d0e5

File tree

7 files changed

+437
-27
lines changed

7 files changed

+437
-27
lines changed

build/Build-Extension.ps1

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
2+
<#PSScriptInfo
3+
4+
.VERSION 1.0.0
5+
6+
.GUID 6312d879-4b8c-4d88-aa39-bf245069148e
7+
8+
.AUTHOR Markus Szumovski
9+
10+
.COMPANYNAME -
11+
12+
.COPYRIGHT 2021
13+
14+
.TAGS
15+
16+
.LICENSEURI
17+
18+
.PROJECTURI
19+
20+
.ICONURI
21+
22+
.EXTERNALMODULEDEPENDENCIES
23+
24+
.REQUIREDSCRIPTS
25+
26+
.EXTERNALSCRIPTDEPENDENCIES
27+
28+
.RELEASENOTES
29+
V 1.0.0: Initial version
30+
31+
.PRIVATEDATA
32+
33+
#>
34+
35+
<#
36+
37+
.SYNOPSIS
38+
Will build the extension.
39+
.DESCRIPTION
40+
Will build the extension.
41+
.PARAMETER ExtensionRepositoryRoot
42+
The path to the extension repository root from where to build the extension from.
43+
Will default to parent directory of script if no path or $null was provided.
44+
.PARAMETER BuildEnvironment
45+
Set to "Release" for production environment or set to anything else (for example "Development") for development environment.
46+
If nothing was provided the Release environment will be built.
47+
.PARAMETER BuildVersion
48+
If provided will set the version number.
49+
If not provided the version number will not be changed.
50+
.PARAMETER NoPackaging
51+
If the switch was provided, the built extension will not be packaged up into a vsix file.
52+
.OUTPUTS
53+
Building and packaging progress
54+
55+
.EXAMPLE
56+
Build-Extension -BuildVersion "6.1.0.1" -BuildEnvironment "Release"
57+
#>
58+
[CmdletBinding(SupportsShouldProcess=$True)]
59+
Param
60+
(
61+
[Parameter(Position=0)]
62+
[string] $ExtensionRepositoryRoot = $null,
63+
[Parameter(Position=1)]
64+
[string] $BuildEnvironment = "Release",
65+
[Parameter(Position=2)]
66+
[string] $BuildVersion = $null,
67+
[Parameter(Position=3)]
68+
[switch] $NoPackaging
69+
70+
)
71+
72+
### --- START --- functions
73+
### --- END --- functions
74+
75+
### --- START --- main script ###
76+
try {
77+
Write-Host "--- Build extension script started ---`r`n`r`n" -ForegroundColor DarkGreen
78+
79+
if([string]::IsNullOrWhiteSpace($ExtensionRepositoryRoot)) {
80+
Write-Host "No extension repository root provided, determining path now..."
81+
$ExtensionRepositoryRoot = Split-Path -Path (Split-Path -Path $MyInvocation.MyCommand.Path -Parent -ErrorAction Stop) -Parent -ErrorAction Stop
82+
Write-Host ""
83+
}
84+
else {
85+
$ExtensionRepositoryRoot = Resolve-Path -Path $ExtensionRepositoryRoot -ErrorAction Ignore
86+
}
87+
88+
if([string]::IsNullOrWhiteSpace($BuildEnvironment)) {
89+
$BuildEnvironment = "Release"
90+
}
91+
92+
# Set build env vars
93+
if ($BuildEnvironment -eq "Release") {
94+
$TaskId = "47EA1F4A-57BA-414A-B12E-C44F42765E72"
95+
$TaskName = "dependency-check-build-task"
96+
$VssExtensionName = "vss-extension.prod.json"
97+
}
98+
else {
99+
$TaskId = "04450B31-9F11-415A-B37A-514D69EF69A1"
100+
$TaskName = "dependency-check-build-task-dev"
101+
$VssExtensionName = "vss-extension.dev.json"
102+
}
103+
104+
$ExtensionRepositoryRootExists = Test-Path -Path $ExtensionRepositoryRoot -ErrorAction Ignore
105+
106+
if($ExtensionRepositoryRootExists) {
107+
$TaskFolderPath = Join-Path -Path $ExtensionRepositoryRoot -ChildPath "src\Tasks\dependency-check-build-task" -ErrorAction Stop
108+
109+
$TaskDefPath = Join-Path -Path $TaskFolderPath -ChildPath "task.json" -ErrorAction Stop
110+
$TaskDefExists = Test-Path -Path $TaskDefPath -ErrorAction Ignore
111+
112+
$VssExtensionPath = Join-Path -Path $ExtensionRepositoryRoot -ChildPath $VssExtensionName -ErrorAction Stop
113+
$VssExtensionExists = Test-Path -Path $VssExtensionPath -ErrorAction Ignore
114+
}
115+
else {
116+
$TaskFolderPath = $null
117+
$TaskDefPath = $null
118+
$TaskDefExists = $false
119+
$VssExtensionPath = $null
120+
$VssExtensionExists = $false
121+
}
122+
123+
#Parse version vars
124+
$VerPatchRevision = $null
125+
if(![string]::IsNullOrWhiteSpace($BuildVersion)) {
126+
$VerMajor,$VerMinor,$VerPatch,$VerRevision = $BuildVersion.Split('.')
127+
if($null -eq $VerMajor) {
128+
$VerMajor = 0
129+
}
130+
if($null -eq $VerMinor) {
131+
$VerMinor = 0
132+
}
133+
if($null -eq $VerPatch) {
134+
$VerPatch = 0
135+
}
136+
if($null -eq $VerRevision) {
137+
$VerRevision = 0
138+
}
139+
$VerPatchRevision = [string]::Format("{0}{1}", $VerPatch, $VerRevision.PadLeft(3, '0'))
140+
$BuildVersion = "$VerMajor.$VerMinor.$VerPatch.$VerRevision"
141+
$BuildTaskVersion = "$VerMajor.$VerMinor.$VerPatchRevision"
142+
}
143+
144+
145+
Write-Host "------------------------------"
146+
147+
Write-Host "Extension repository root: ""$ExtensionRepositoryRoot"" (" -NoNewline
148+
if($ExtensionRepositoryRootExists) {
149+
Write-Host "exists" -ForegroundColor Green -NoNewline
150+
}
151+
else {
152+
Write-Host "missing" -ForegroundColor Red -NoNewline
153+
}
154+
Write-Host ")"
155+
156+
Write-Host "Task definition JSON: ""$TaskDefPath"" (" -NoNewline
157+
if($TaskDefExists) {
158+
Write-Host "exists" -ForegroundColor Green -NoNewline
159+
}
160+
else {
161+
Write-Host "missing" -ForegroundColor Red -NoNewline
162+
}
163+
Write-Host ")"
164+
165+
Write-Host "VSS extension JSON: ""$VssExtensionPath"" (" -NoNewline
166+
if($VssExtensionExists) {
167+
Write-Host "exists" -ForegroundColor Green -NoNewline
168+
}
169+
else {
170+
Write-Host "missing" -ForegroundColor Red -NoNewline
171+
}
172+
Write-Host ")"
173+
174+
Write-Host "Build environment: $BuildEnvironment"
175+
if([string]::IsNullOrWhiteSpace($BuildVersion)) {
176+
Write-Host "Build version: <none defined>"
177+
}
178+
else {
179+
Write-Host "Build version: $BuildVersion"
180+
Write-Host "Build-Task version: $BuildTaskVersion"
181+
}
182+
183+
Write-Host "Task-Id: $TaskId"
184+
Write-Host "Task-Name: $TaskName"
185+
Write-Host "VSS extension JSON: $VssExtensionName"
186+
187+
Write-Host "------------------------------`r`n"
188+
189+
if($ExtensionRepositoryRootExists) {
190+
if($TaskDefExists) {
191+
192+
Write-Host "Reading task.json..."
193+
$TaskJson = Get-Content -Path $TaskDefPath -Raw | ConvertFrom-Json
194+
195+
Write-Host "Setting task definition id and name..."
196+
$TaskJson.id = $TaskId
197+
$TaskJson.name = $TaskName
198+
199+
if([string]::IsNullOrWhiteSpace($BuildVersion)) {
200+
Write-Host "(Skipping setting of task definition version since no version was provided)"
201+
}
202+
else {
203+
Write-Host "Setting task definition version..."
204+
$TaskJson.version.Major = $VerMajor
205+
$TaskJson.version.Minor = $VerMinor
206+
$TaskJson.version.Patch = $VerPatchRevision
207+
}
208+
209+
Write-Host "Saving new task definition..."
210+
$TaskJson | ConvertTo-Json -Depth 100 | Set-Content -Path $TaskDefPath
211+
212+
if([string]::IsNullOrWhiteSpace($BuildVersion)) {
213+
Write-Host "(Skipping setting of extension version since no version was provided)"
214+
}
215+
else {
216+
Write-Host "Reading ""$VssExtensionName""..."
217+
$VssExtensionJson = Get-Content -Path $VssExtensionPath -Raw | ConvertFrom-Json
218+
219+
Write-Host "Setting version"
220+
$VssExtensionJson.version = $BuildVersion
221+
222+
Write-Host "Saving new extension definition..."
223+
$VssExtensionJson | ConvertTo-Json -Depth 100 | Set-Content $VssExtensionPath
224+
}
225+
226+
Write-Host "`r`nBuilding task..."
227+
Write-Host "------------------------------"
228+
Push-Location
229+
Set-Location -Path $TaskFolderPath
230+
&"npm" install
231+
&"npm" run build
232+
Pop-Location
233+
Write-Host "------------------------------"
234+
Write-Host "`r`nBuilding extension..."
235+
Write-Host "------------------------------"
236+
&"npm" install
237+
&"npm" run build
238+
Write-Host "------------------------------"
239+
240+
if(!$NoPackaging.IsPresent) {
241+
Write-Host "`r`nPackaging..."
242+
if($BuildEnvironment -eq "Release") {
243+
&"npm" run package-prod
244+
}
245+
else {
246+
&"npm" run package-dev
247+
}
248+
249+
Write-Host "`r`nBuilding and packaging extension..." -NoNewline
250+
}
251+
else {
252+
Write-Host "`r`nBuilding extension..." -NoNewline
253+
}
254+
255+
Write-Host "DONE" -ForegroundColor Green
256+
}
257+
else {
258+
Write-Warning "Task.json not found, cannot continue"
259+
}
260+
}
261+
else {
262+
Write-Warning "Extension repository root not found, cannot continue"
263+
}
264+
}
265+
finally {
266+
Write-Host "`r`n`r`n--- Build extension script ended ---" -ForegroundColor DarkGreen
267+
}
268+
269+
#and we're at the end
270+
271+
### --- END --- main script ###

build/README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@ Let's start with this: We can automate this with a pipeline later and eliminate
44

55
Start by making your changes to the extension. When you are ready to test and release, use the steps below.
66

7-
## Build Task Version
7+
## PowerShell Core building
8+
9+
The simplest way to create a new vsix package for development or production environment is to use the ./build/Build-Extension.ps1 PowerShell Core script (PowerShell Core needs to be installed for this script to work).
10+
11+
Just call it via `pwsh ./build/Build-Extension.ps1 -BuildVersion "6.1.0.0" -BuildEnvironment "Release"` and replace the -BuildVersion string with the new version number and use "Release" as BuildEnvironment for production and "Development" as BuildEnvironment for development.
12+
13+
After the call the new VSIX file should have been created in the repository root directory.
14+
15+
## Manual building
16+
17+
### Build Task Version
818

919
To release a new version, start by opening the *src/Tasks/dependency-check-build-task/task.json* file. Bump the version number. Keep the major and minor versions in sync with the core Dependency Check CLI. The patch release has to be updated every time you want to change the extension. Even in development. Think of it like a build number. Azure won't update the build task during an update if this value is the same as the currently installed build task in a pipeline. So, we put some 0's on th end to tell us what version of Dependency Check we are using, as well as the build id of the extension itself. Example 5.1.1 = 5.1.\[1000-1999\].
1020

@@ -16,7 +26,7 @@ To release a new version, start by opening the *src/Tasks/dependency-check-build
1626
},
1727
```
1828

19-
## Building for DEV
29+
### Building for DEV
2030

2131
Open the **package.json** file and modify the package line:
2232

@@ -58,7 +68,7 @@ dependency-check.azuredevops-dev-5.2.0.000.vsix
5868

5969
Upload the the marketplace manually (for now until the release pipeline works)
6070

61-
## Build for PROD
71+
### Build for PROD
6272

6373
Open the **package.json** file and update the package command to the prod value:
6474

overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The OWASP Dependency Check Azure DevOps Extension enables the following features
1212

1313
## GitHub Repository
1414

15-
The extension maintainers do not monitor the Marketplace Question & Answers. please use the [Azure DevOps Dependency Check](https://github.com/dependency-check/azuredevops) repository for questions, issues, or enhancements.
15+
The extension maintainers do not monitor the Marketplace Question & Answers. Please use the [Azure DevOps Dependency Check](https://github.com/dependency-check/azuredevops) repository for questions, issues, or enhancements.
1616

1717
## Installation and Configuration
1818

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)