forked from microsoft/Build-OMS-Agent-for-Linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipeline-dsc-packaging.ps1
More file actions
43 lines (35 loc) · 1.41 KB
/
Copy pathpipeline-dsc-packaging.ps1
File metadata and controls
43 lines (35 loc) · 1.41 KB
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
Add-Type -Assembly System.IO.Compression.FileSystem
Function AddtoExistingZip ($ZIPFileName,$newFileToAdd,$target)
{
try
{
$fileName = [System.IO.Path]::GetFileName($newFileToAdd)
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') | Out-Null
$zip = [System.IO.Compression.ZipFile]::Open($ZIPFileName,"Update")
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip,$newFileToAdd,$target,"Optimal") | Out-Null
$zip.Dispose()
} catch {
Write-Warning "Failed to add $NewFileToAdd to $ZIPFileName . Details : $_"
$zip.Dispose()
}
}
$pipelinePath = Join-Path .\ pipeline-signing
$workingPath = $(Resolve-Path $pipelinePath)
Write-Host "pipelinePath = ${workingPath}"
$dscPath = Join-Path $workingPath "dsc"
Write-Host "dscPath = ${dscPath}"
$signingPath = Join-Path $dscPath "signing"
Write-Host "signingPath = ${signingPath}"
Xcopy $dscPath\*.zip $signingPath /Y /M
dir $signingPath
$files = Get-ChildItem $signingPath -Filter *.zip
for ($i=0; $i -lt $files.Count; $i++) {
$zipPath = $files[$i].FullName
$moduleName = $files[$i].BaseName
$fileName = $files[$i].BaseName + ".asc"
$signedFilePATH = Join-Path $signingPath $fileName
Write-Host "Adding signed file '${fileName}' to '${zipPath}'..."
$targetPath = $moduleName + "/" + $fileName
AddtoExistingZip $zipPATH $signedFilePATH $targetPath
rm $signedFilePATH
}