Skip to content

Commit 51cdefe

Browse files
authoredApr 20, 2024··
Merge pull request #413 from SteveL-MSFT/onebranch
Release pipeline updates
2 parents d8a12d3 + 61b152d commit 51cdefe

File tree

2 files changed

+239
-118
lines changed

2 files changed

+239
-118
lines changed
 

‎.pipelines/DSC-Official.yml

+69-37
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: DSC-Release-$(Build.BuildId)
22
trigger: none
33

4+
parameters:
5+
- name: 'debugConsole'
6+
displayName: 'Enable debug console'
7+
type: boolean
8+
default: false
9+
410
pr:
511
branches:
612
include:
@@ -23,6 +29,8 @@ resources:
2329
extends:
2430
template: v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates
2531
parameters:
32+
featureFlags:
33+
debugConsole: ${{ parameters.debugConsole }}
2634
customTags: 'ES365AIMigrationTooling'
2735
globalSdl:
2836
disableLegacyManifest: true
@@ -58,7 +66,6 @@ extends:
5866
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
5967
steps:
6068
- checkout: self
61-
target: host
6269
- pwsh: |
6370
$packageVersion = $(repoRoot)/build.ps1 -GetPackageVersion
6471
$vstsCommandString = "vso[task.setvariable variable=Version;isoutput=true]$packageVersion"
@@ -71,77 +78,96 @@ extends:
7178
strategy:
7279
matrix:
7380
Windows x64:
81+
Suffix: x64
7482
buildName: x86_64-pc-windows-msvc
7583
Windows x64_arm64:
84+
Suffix: arm64
7685
buildName: aarch64-pc-windows-msvc
7786
variables:
7887
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
79-
ob_sdl_tsa_configFile: $(Build.SourcesDirectory)\DSC\.config\tsaoptions.json
88+
ob_sdl_tsa_configFile: '$(Build.SourcesDirectory)\DSC\.config\tsaoptions.json'
8089
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
81-
repoRoot: $(Build.SourcesDirectory)\DSC
82-
signSrcPath: $(repoRoot)/out
83-
ob_artifactBaseName: 'DSC-$(buildName)'
90+
ob_artifactSuffix: $(Suffix)
91+
repoRoot: '$(Build.SourcesDirectory)\DSC'
92+
signSrcPath: '$(Build.SourcesDirectory)\out'
8493
ob_sdl_sbom_enabled: true
8594
ob_signing_setup_enabled: true
8695
ob_sdl_codeql_compiled_enabled: false
8796
pool:
8897
type: windows
89-
displayName: Build
98+
displayName: BuildWin
9099
steps:
91100
- checkout: self
92-
target: host
101+
env:
102+
ob_restore_phase: true
93103
- task: CodeQL3000Init@0 # Add CodeQL Init task right before your 'Build' step.
94104
inputs:
95105
Enabled: true
96106
AnalyzeInPipeline: true
97107
Language: rust
108+
env:
109+
ob_restore_phase: true
98110
- pwsh: |
99-
$tmpdir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())
100-
New-Item -ItemType Directory -Path $tmpdir
111+
$tmpdir = "$(Agent.TempDirectory)"
101112
Write-Host "##vso[task.setvariable variable=CARGO_TARGET_DIR;]$tmpdir"
102113
displayName: 🛠️ Workaround for the LoadLibrary ACCESS_VIOLATION OneBranch issue
114+
env:
115+
ob_restore_phase: true
103116
- pwsh: |
104117
Set-Location "$(Build.SourcesDirectory)/DSC"
105118
./build.ps1 -Release -Architecture $(buildName) -SkipLinkCheck
106119
displayName: 'Build $(buildName)'
120+
env:
121+
ob_restore_phase: true
107122
condition: succeeded()
108123
- task: CodeQL3000Finalize@0 # Add CodeQL Finalize task right after your 'Build' step.
109124
condition: always()
125+
env:
126+
ob_restore_phase: true
110127
- pwsh: |
111128
$null = New-Item -ItemType Directory -Path "$(PackageRoot)" -ErrorAction Ignore
112129
$null = New-Item -ItemType Directory -Path "$(PackageRoot)/out" -ErrorAction Ignore
113-
$outPath = New-Item -ItemType Directory -Path "$(PackageRoot)/out/$(buildName)" -ErrorAction Ignore
130+
$null = New-Item -ItemType Directory -Path "$(signSrcPath)" -ErrorAction Ignore
114131
# workaround known issue of building in OneBranch copying from TMP folder
115132
$null = New-Item -ItemType Directory -Path "$(signSrcPath)" -ErrorAction Ignore
116133
# copy only the exes from the TMP folder since it contains intermediately built files we don't want to sign
117-
Copy-Item "$env:CARGO_TARGET_DIR/*.exe" "$(signSrcPath)"
118-
# Copy-Item -Path "$(Build.SourcesDirectory)/DSC/bin/$(buildName)/$(BuildConfiguration)/*" -Destination $outPath -Verbose -Force
119-
displayName: Copy binaries
134+
write-host 'Binaries in $(env:CARGO_TARGET_DIR)'
135+
Copy-Item -Path "$env:CARGO_TARGET_DIR/$(buildName)/$(BuildConfiguration)/*.exe" -Destination "$(signSrcPath)" -Verbose
136+
Copy-Item -Path "$(Build.SourcesDirectory)/DSC/bin/$(buildName)/$(BuildConfiguration)/*" -Recurse -Destination "$(signSrcPath)" -Verbose -Force
137+
write-host 'Binaries in $(signSrcPath)'
138+
dir -r "$(signSrcPath)"
139+
displayName: Copy built binaries
140+
env:
141+
ob_restore_phase: true
120142
condition: succeeded()
121143
- task: onebranch.pipeline.signing@1
122144
displayName: Sign 1st party files
123145
inputs:
124146
command: 'sign'
125147
signing_profile: external_distribution
126148
files_to_sign: |
127-
*.exe;
128-
*.json;
129-
*.ps1;
149+
**\*.exe;
150+
**\*.ps1;
151+
**\*.psd1;
152+
**\*.psm1;
130153
search_root: $(signSrcPath)
131154
- task: CopyFiles@2
132-
displayName: "Copy signed files to ob_outputDirectory - '$(ob_outputDirectory)'"
155+
displayName: "Copy signed files to build target dir"
133156
inputs:
134157
SourceFolder: "$(signSrcPath)"
135-
Contents: '*'
136-
TargetFolder: $(ob_outputDirectory)
158+
Contents: '**'
159+
TargetFolder: $(Build.SourcesDirectory)/DSC/bin/$(buildName)/$(BuildConfiguration)
160+
OverWrite: true
137161
- pwsh: |
138-
compress-archive -Path "$(ob_outputDirectory)/*" -DestinationPath "$(ob_outputDirectory)/DSC-$(PackageVersion)-$(buildName).zip"
139-
displayName: 'Compress $(buildName)'
162+
Set-Location "$(Build.SourcesDirectory)/DSC"
163+
./build.ps1 -PackageType zip -Architecture $(buildName) -Release
164+
Copy-Item ./bin/*.zip "$(ob_outputDirectory)"
165+
displayName: 'Zip $(buildName)'
140166
condition: succeeded()
141167
- pwsh: |
142168
Set-Location "$(Build.SourcesDirectory)/DSC"
143-
./build.ps1 -msix -skipbuild
144-
Copy-Item *.msix "$(ob_outputDirectory)"
169+
./build.ps1 -PackageType msix -Architecture $(buildName) -Release -UseX64MakeAppx
170+
Copy-Item ./bin/msix/*.msix "$(ob_outputDirectory)" -Verbose
145171
displayName: 'Create msix for $(buildName)'
146172
condition: succeeded()
147173
@@ -152,9 +178,20 @@ extends:
152178
pool:
153179
type: windows
154180
steps:
181+
- download: current
182+
artifact: drop_BuildAndSign_BuildWinx64
183+
patterns: '*.msix'
184+
- download: current
185+
artifact: drop_BuildAndSign_BuildWinarm64
186+
patterns: '*.msix'
187+
- checkout: self
155188
- pwsh: |
156189
Set-Location "$(Build.SourcesDirectory)/DSC"
157-
./build.ps1 -msixbundle
190+
$null = New-Item -ItemType Directory -Path "./bin/msix" -Force -ErrorAction Ignore
191+
Copy-Item "$(Pipeline.Workspace)/drop_BuildAndSign_BuildWinx64/*.msix" ./bin/msix -Verbose
192+
Copy-Item "$(Pipeline.Workspace)/drop_BuildAndSign_BuildWinarm64/*.msix" ./bin/msix -Verbose
193+
./build.ps1 -PackageType msixbundle
194+
Copy-Item ./bin/*.msixbundle "$(ob_outputDirectory)"
158195
displayName: 'Create msixbundle'
159196
condition: succeeded()
160197
@@ -185,12 +222,10 @@ extends:
185222
steps:
186223
- pwsh: |
187224
./build.ps1 -Release -Architecture x86_64-unknown-linux-gnu
225+
./build.ps1 -PackageType tgz -Architecture x86_64-unknown-linux-gnu -Release
226+
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
188227
displayName: 'Build x86_64-unknown-linux-gnu'
189228
condition: succeeded()
190-
- pwsh: |
191-
tar czf '$(ob_outputDirectory)/DSC-$(PackageVersion)-x86_64-unknown-linux-gnu.tar.gz' -C $(Build.SourcesDirectory)/bin/x86_64-unknown-linux-gnu/$(BuildConfiguration) .
192-
displayName: 'Compress x86_64-unknown-linux-gnu'
193-
condition: succeeded()
194229
195230
- job: BuildLinuxArm64
196231
dependsOn: SetPackageVersion
@@ -204,19 +239,17 @@ extends:
204239
steps:
205240
- pwsh: |
206241
./build.ps1 -Release -Architecture aarch64-unknown-linux-gnu
242+
./build.ps1 -PackageType tgz -Architecture aarch64-unknown-linux-gnu -Release
243+
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
207244
displayName: 'Build aarch64-unknown-linux-gnu'
208245
condition: succeeded()
209-
- pwsh: |
210-
tar czf '$(ob_outputDirectory)/DSC-$(PackageVersion)-aarch64-unknown-linux-gnu.tar.gz' -C $(Build.SourcesDirectory)/bin/aarch64-unknown-linux-gnu/$(BuildConfiguration) .
211-
displayName: 'Compress aarch64-unknown-linux-gnu'
212-
condition: succeeded()
213246
214247
- job: BuildMac
215248
dependsOn: SetPackageVersion
216249
variables:
217250
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
218251
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
219-
displayName: Build
252+
displayName: BuildMac
220253
pool:
221254
type: linux
222255
isCustom: true
@@ -231,12 +264,11 @@ extends:
231264
steps:
232265
- pwsh: |
233266
./build.ps1 -Release -Architecture $(buildName)
267+
./build.ps1 -PackageType tgz -Architecture $(buildName) -Release
268+
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
269+
Write-Host "##vso[artifact.upload containerfolder=release;artifactname=release]$(ob_outputDirectory)/DSC-$(PackageVersion)-$(buildName).tar.gz"
234270
displayName: 'Build $(buildName)'
235271
condition: succeeded()
236-
- pwsh: |
237-
tar czf '$(ob_outputDirectory)/DSC-$(PackageVersion)-$(buildName).tar.gz' -C $(Build.SourcesDirectory)/bin/$(buildName)/$(BuildConfiguration) .
238-
displayName: 'Compress $(buildName)'
239-
condition: succeeded()
240272
241273
- stage: Release
242274
dependsOn: BuildAndSign

‎build.ps1

+170-81
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ param(
77
$architecture = 'current',
88
[switch]$Clippy,
99
[switch]$SkipBuild,
10-
[switch]$Msix,
11-
[switch]$MsixBundle,
10+
[ValidateSet('msix','msixbundle','tgz','zip')]
11+
$packageType,
1212
[switch]$Test,
1313
[switch]$GetPackageVersion,
14-
[switch]$SkipLinkCheck
14+
[switch]$SkipLinkCheck,
15+
[switch]$UseX64MakeAppx
1516
)
1617

1718
if ($GetPackageVersion) {
@@ -23,28 +24,45 @@ if ($GetPackageVersion) {
2324
return $match.Matches.Groups[1].Value
2425
}
2526

26-
## Test if Rust is installed
27-
if (!(Get-Command 'cargo' -ErrorAction Ignore)) {
28-
Write-Verbose -Verbose "Rust not found, installing..."
29-
if (!$IsWindows) {
30-
curl https://sh.rustup.rs -sSf | sh -s -- -y
31-
$env:PATH += ":$env:HOME/.cargo/bin"
32-
}
33-
else {
34-
Invoke-WebRequest 'https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe' -OutFile 'temp:/rustup-init.exe'
35-
Write-Verbose -Verbose "Use the default settings to ensure build works"
36-
& 'temp:/rustup-init.exe' -y
37-
$env:PATH += ";$env:USERPROFILE\.cargo\bin"
38-
Remove-Item temp:/rustup-init.exe -ErrorAction Ignore
39-
}
40-
}
27+
$filesForWindowsPackage = @(
28+
'dsc.exe',
29+
'assertion.dsc.resource.json',
30+
'group.dsc.resource.json',
31+
'powershell.dsc.resource.json',
32+
'PSDesiredStateConfiguration/',
33+
'psDscAdapter/',
34+
'reboot_pending.dsc.resource.json',
35+
'reboot_pending.resource.ps1',
36+
'registry.dsc.resource.json',
37+
'registry.exe',
38+
'RunCommandOnSet.dsc.resource.json',
39+
'RunCommandOnSet.exe',
40+
'windowspowershell.dsc.resource.json',
41+
'wmi.dsc.resource.json',
42+
'wmi.resource.ps1'
43+
)
4144

42-
if ($IsLinux -and (Test-Path /etc/mariner-release)) {
43-
tdnf install -y openssl-devel
44-
}
45+
$filesForLinuxPackage = @(
46+
'dsc',
47+
'assertion.dsc.resource.json',
48+
'group.dsc.resource.json',
49+
'powershell.dsc.resource.json',
50+
'psDscAdapter/',
51+
'RunCommandOnSet.dsc.resource.json',
52+
'runcommandonset'
53+
)
4554

46-
rustup default stable
47-
$BuildToolsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC"
55+
$filesForMacPackage = @(
56+
'dsc',
57+
'assertion.dsc.resource.json',
58+
'brew.dsc.resource.json',
59+
'brew.dsc.resource.sh',
60+
'group.dsc.resource.json',
61+
'powershell.dsc.resource.json',
62+
'psDscAdapter/',
63+
'RunCommandOnSet.dsc.resource.json',
64+
'runcommandonset'
65+
)
4866

4967
function Find-LinkExe {
5068
try {
@@ -61,8 +79,32 @@ function Find-LinkExe {
6179
}
6280
}
6381

64-
if ($Msix -or $MsixBundle) {
82+
if ($null -ne $packageType) {
6583
$SkipBuild = $true
84+
} else {
85+
## Test if Rust is installed
86+
if (!(Get-Command 'cargo' -ErrorAction Ignore)) {
87+
Write-Verbose -Verbose "Rust not found, installing..."
88+
if (!$IsWindows) {
89+
curl https://sh.rustup.rs -sSf | sh -s -- -y
90+
$env:PATH += ":$env:HOME/.cargo/bin"
91+
}
92+
else {
93+
Invoke-WebRequest 'https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe' -OutFile 'temp:/rustup-init.exe'
94+
Write-Verbose -Verbose "Use the default settings to ensure build works"
95+
& 'temp:/rustup-init.exe' -y
96+
$env:PATH += ";$env:USERPROFILE\.cargo\bin"
97+
Remove-Item temp:/rustup-init.exe -ErrorAction Ignore
98+
}
99+
}
100+
101+
if ($IsLinux -and (Test-Path /etc/mariner-release)) {
102+
tdnf install -y openssl-devel
103+
}
104+
105+
$BuildToolsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC"
106+
107+
rustup default stable
66108
}
67109

68110
if (!$SkipBuild -and !$SkipLinkCheck -and $IsWindows -and !(Get-Command 'link.exe' -ErrorAction Ignore)) {
@@ -111,35 +153,38 @@ else {
111153
}
112154

113155
if (!$SkipBuild) {
114-
if (Test-Path $target) {
115-
Remove-Item $target -Recurse -ErrorAction Stop
116-
}
117-
New-Item -ItemType Directory $target > $null
118-
119-
# make sure dependencies are built first so clippy runs correctly
120-
$windows_projects = @("pal", "registry", "reboot_pending", "wmi-adapter")
121-
122-
# projects are in dependency order
123-
$projects = @(
124-
"tree-sitter-dscexpression",
125-
"security_context_lib",
126-
"dsc_lib",
127-
"dsc",
128-
"osinfo",
129-
"powershell-adapter",
130-
"process",
131-
"tools/dsctest",
132-
"tools/test_group_resource",
133-
"y2j",
134-
"resources/brew",
135-
"runcommandonset"
136-
)
137-
$pedantic_unclean_projects = @()
138-
$clippy_unclean_projects = @("tree-sitter-dscexpression")
139-
$skip_test_projects_on_windows = @("tree-sitter-dscexpression")
156+
if (Test-Path $target) {
157+
Remove-Item $target -Recurse -ErrorAction Ignore
158+
}
159+
New-Item -ItemType Directory $target -ErrorAction Ignore > $null
160+
161+
# make sure dependencies are built first so clippy runs correctly
162+
$windows_projects = @("pal", "registry", "reboot_pending", "wmi-adapter")
163+
164+
# projects are in dependency order
165+
$projects = @(
166+
"tree-sitter-dscexpression",
167+
"security_context_lib",
168+
"dsc_lib",
169+
"dsc",
170+
"osinfo",
171+
"powershell-adapter",
172+
"process",
173+
"resources/brew",
174+
"runcommandonset",
175+
"tools/dsctest",
176+
"tools/test_group_resource",
177+
"y2j"
178+
)
179+
$pedantic_unclean_projects = @()
180+
$clippy_unclean_projects = @("tree-sitter-dscexpression")
181+
$skip_test_projects_on_windows = @("tree-sitter-dscexpression")
140182

141183
if ($IsWindows) {
142184
$projects += $windows_projects
185+
Save-Module -Path $target -Name 'PSDesiredStateConfiguration' -RequiredVersion '2.0.7' -Repository PSGallery -Force
186+
# Need to unhide all the files so that packaging works
187+
Get-ChildItem -Path $target -Recurse -Hidden | ForEach-Object { $_.Attributes = 'Normal' }
143188
}
144189

145190
$failed = $false
@@ -216,8 +261,8 @@ $skip_test_projects_on_windows = @("tree-sitter-dscexpression")
216261
}
217262
}
218263

219-
$relative = Resolve-Path $target -Relative
220-
if (!$Clippy) {
264+
if (!$Clippy -and !$SkipBuild) {
265+
$relative = Resolve-Path $target -Relative
221266
Write-Host -ForegroundColor Green "`nEXE's are copied to $target ($relative)"
222267

223268
# remove the other target in case switching between them
@@ -318,7 +363,7 @@ function Find-MakeAppx() {
318363
$makeappx = Get-Command makeappx -CommandType Application -ErrorAction Ignore
319364
if ($null -eq $makeappx) {
320365
# try to find
321-
if ($architecture -eq 'aarch64-pc-windows-msvc') {
366+
if (!$UseX64MakeAppx -and $architecture -eq 'aarch64-pc-windows-msvc') {
322367
$arch = 'arm64'
323368
}
324369
else {
@@ -334,24 +379,19 @@ function Find-MakeAppx() {
334379
$makeappx
335380
}
336381

337-
if ($MsixBundle) {
338-
if ($Msix) {
339-
throw "Creating MsixBundle requires all msix packages to already be created"
340-
}
382+
$productVersion = ((Get-Content $PSScriptRoot/dsc/Cargo.toml) -match '^version\s*=\s*') -replace 'version\s*=\s*"(.*?)"', '$1'
341383

384+
if ($packageType -eq 'msixbundle') {
342385
if (!$IsWindows) {
343386
throw "MsixBundle is only supported on Windows"
344387
}
345388

346-
$productVersion = ((Get-Content $PSScriptRoot/dsc/Cargo.toml) -match '^version\s*=\s*') -replace 'version\s*=\s*"(.*?)"', '$1'
347-
$isPreview = $productVersion -like '*-*'
348389
$packageName = "DSC-$productVersion-Win"
349390
$makeappx = Find-MakeAppx
350-
& $makeappx bundle /d $PSScriptRoot /p "$PSScriptRoot\$packageName.msixbundle"
391+
$msixPath = Join-Path $PSScriptRoot 'bin' 'msix'
392+
& $makeappx bundle /d $msixPath /p "$PSScriptRoot\bin\$packageName.msixbundle"
351393
return
352-
}
353-
354-
if ($Msix) {
394+
} elseif ($packageType -eq 'msix') {
355395
if (!$IsWindows) {
356396
throw "MSIX is only supported on Windows"
357397
}
@@ -363,7 +403,6 @@ if ($Msix) {
363403
$makeappx = Find-MakeAppx
364404
$makepri = Get-Item (Join-Path $makeappx.Directory "makepri.exe") -ErrorAction Stop
365405
$displayName = "DesiredStateConfiguration"
366-
$productVersion = ((Get-Content $PSScriptRoot/dsc/Cargo.toml) -match '^version\s*=\s*') -replace 'version\s*=\s*"(.*?)"', '$1'
367406
$isPreview = $productVersion -like '*-*'
368407
$productName = "DesiredStateConfiguration"
369408
if ($isPreview) {
@@ -389,25 +428,18 @@ if ($Msix) {
389428
$appxManifest = $appxManifest.Replace('$VERSION$', $ProductVersion).Replace('$ARCH$', $Arch).Replace('$PRODUCTNAME$', $productName).Replace('$DISPLAYNAME$', $displayName).Replace('$PUBLISHER$', $releasePublisher)
390429
$msixTarget = Join-Path $PSScriptRoot 'bin' $architecture 'msix'
391430
if (Test-Path $msixTarget) {
392-
Remove-Item $msixTarget -Recurse -ErrorAction Stop
431+
Remove-Item $msixTarget -Recurse -ErrorAction Stop -Force
393432
}
394433

395434
New-Item -ItemType Directory $msixTarget > $null
396435
Set-Content -Path "$msixTarget\AppxManifest.xml" -Value $appxManifest -Force
397436

398-
$filesForMsix = @(
399-
'dsc.exe',
400-
'assertion.dsc.resource.json',
401-
'group.dsc.resource.json',
402-
'parallel.dsc.resource.json',
403-
'powershellgroup.dsc.resource.json',
404-
'powershellgroup.resource.ps1',
405-
'wmigroup.dsc.resource.json.optout',
406-
'wmigroup.resource.ps1'
407-
)
408-
409-
foreach ($file in $filesForMsix) {
410-
Copy-Item "$target\$file" $msixTarget -ErrorAction Stop
437+
foreach ($file in $filesForWindowsPackage) {
438+
if ((Get-Item "$target\$file") -is [System.IO.DirectoryInfo]) {
439+
Copy-Item "$target\$file" "$msixTarget\$file" -Recurse -ErrorAction Stop
440+
} else {
441+
Copy-Item "$target\$file" $msixTarget -ErrorAction Stop
442+
}
411443
}
412444

413445
# Necessary image assets need to be in source assets folder
@@ -440,12 +472,69 @@ if ($Msix) {
440472
}
441473

442474
Write-Verbose "Creating msix package" -Verbose
443-
$packageName = "$productName-$productVersion-$arch"
444-
& $makeappx pack /o /v /h SHA256 /d $msixTarget /p (Join-Path -Path (Get-Location) -ChildPath "$packageName.msix")
475+
476+
$targetFolder = Join-Path $PSScriptRoot 'bin' 'msix'
477+
if (Test-Path $targetFolder) {
478+
Remove-Item $targetFolder -Recurse -ErrorAction Stop -Force
479+
} else {
480+
New-Item -ItemType Directory $targetFolder > $null
481+
}
482+
483+
$packageName = Join-Path $targetFolder "$productName-$productVersion-$arch.msix"
484+
& $makeappx pack /o /v /h SHA256 /d $msixTarget /p $packageName
445485
if ($LASTEXITCODE -ne 0) {
446486
throw "Failed to create msix package"
447487
}
448-
Write-Verbose "Created $packageName.msix" -Verbose
488+
489+
Write-Host -ForegroundColor Green "`nMSIX package is created at $packageName.msix"
490+
} elseif ($packageType -eq 'zip') {
491+
$zipTarget = Join-Path $PSScriptRoot 'bin' $architecture 'zip'
492+
if (Test-Path $zipTarget) {
493+
Remove-Item $zipTarget -Recurse -ErrorAction Stop -Force
494+
}
495+
496+
New-Item -ItemType Directory $zipTarget > $null
497+
498+
foreach ($file in $filesForWindowsPackage) {
499+
if ((Get-Item "$target\$file") -is [System.IO.DirectoryInfo]) {
500+
Copy-Item "$target\$file" "$zipTarget\$file" -Recurse -ErrorAction Stop
501+
} else {
502+
Copy-Item "$target\$file" $zipTarget -ErrorAction Stop
503+
}
504+
}
505+
506+
$packageName = "DSC-$productVersion-$architecture.zip"
507+
$zipFile = Join-Path $PSScriptRoot 'bin' $packageName
508+
Compress-Archive -Path "$zipTarget/*" -DestinationPath $zipFile -Force
509+
Write-Host -ForegroundColor Green "`nZip file is created at $zipFile"
510+
} elseif ($packageType -eq 'tgz') {
511+
$tgzTarget = Join-Path $PSScriptRoot 'bin' $architecture 'tgz'
512+
if (Test-Path $tgzTarget) {
513+
Remove-Item $tgzTarget -Recurse -ErrorAction Stop -Force
514+
}
515+
516+
New-Item -ItemType Directory $tgzTarget > $null
517+
518+
if ($IsLinux) {
519+
$filesForPackage = $filesForLinuxPackage
520+
} elseif ($IsMacOS) {
521+
$filesForPackage = $filesForMacPackage
522+
} else {
523+
Write-Error "Unsupported platform for tgz package"
524+
}
525+
526+
foreach ($file in $filesForPackage) {
527+
if ((Get-Item "$target\$file") -is [System.IO.DirectoryInfo]) {
528+
Copy-Item "$target\$file" "$tgzTarget\$file" -Recurse -ErrorAction Stop
529+
} else {
530+
Copy-Item "$target\$file" $tgzTarget -ErrorAction Stop
531+
}
532+
}
533+
534+
$packageName = "DSC-$productVersion-$architecture.tar.gz"
535+
$tgzFile = Join-Path $PSScriptRoot 'bin' $packageName
536+
tar cvf $tgzFile -C $tgzTarget .
537+
Write-Host -ForegroundColor Green "`nTgz file is created at $tgzFile"
449538
}
450539

451540
$env:RUST_BACKTRACE=1

0 commit comments

Comments
 (0)
Please sign in to comment.