-
Notifications
You must be signed in to change notification settings - Fork 225
/
export-unpack.ps1
45 lines (38 loc) · 1.65 KB
/
export-unpack.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
# Used during dev inner loop to automate unpack on local pc instead of using a pipeline
function Export-Unpack ($solutionName) {
$exportTemp = "export-temp"
$unpackFolder = "$solutionName/SolutionPackage"
$managedZip = "$exportTemp/$solutionName" + "_managed.zip"
$unmanagedZip = "$exportTemp/$solutionName.zip"
if (Test-Path $unmanagedZip) {
Remove-Item $unmanagedZip
}
if (Test-Path $managedZip) {
Remove-Item $managedZip
}
pac solution export --name $solutionName --path $exportTemp
pac solution export --name $solutionName --path $managedZip --managed true
pac solution unpack --zipfile $unmanagedZip --folder $unpackFolder --allowDelete true --packagetype both
$msappFiles = Get-ChildItem -Path "$unpackFolder/CanvasApps" -Filter *.msapp
foreach ($msappFile in $msappFiles) {
$directoryToCreate = $msappFile.FullName.Replace(".msapp", "_msapp_src")
New-Item -Path $directoryToCreate -Type Directory -Force
pac canvas unpack --msapp $msappFile.FullName --sources $directoryToCreate
Remove-Item $msappFile.FullName
}
Get-ChildItem -Path $unpackFolder -Recurse -Filter *.json |
ForEach-Object {
#skip canvas app folder because canvas team already handles this for canvas unpack
if (-not $_.FullName.Contains('CanvasApps')) {
Write-Host $_.FullName
$formatted = jq . $_.FullName --sort-keys
$formatted | Out-File $_.FullName -Encoding UTF8
}
}
Get-ChildItem -Path "$unpackFolder\**\Solution.xml" |
ForEach-Object {
(Get-Content $_.FullName) `
-replace '<Version>[\s\S]*?<\/Version>', '<Version>0.0.0.0</Version>' |
Out-File $_.FullName
}
}