1
- $ErrorActionPreference = " Stop"
2
- $ProgressPreference = " SilentlyContinue"
1
+ $global : ErrorActionPreference = " Stop"
2
+ $global : ProgressPreference = " SilentlyContinue"
3
3
4
4
Write-Host " Running Smoke Test Package Analyis"
5
5
Write-Host " ----------------------------------"
6
6
7
+ # ####
8
+ # This script analyzes the final packaged outputs of
9
+ # There are two things analyzed:
10
+ # - The MSIX UPLOAD package has the raw dependencies before .NET Native compilation,
11
+ # this can help determine the maximum impact of the package if everything were to be included.
12
+ # - The MSIX BUNDLE package is the final .NET Native compiled app,
13
+ # this can be used to help determine the minimal impact of the package if only a few things are used.
14
+ # This is also what would end up on a user's machine and be the footprint of the app itself.
15
+ #
16
+ # Note: The 'minimum impact' can be larger than the 'maximum impact' as there are many
17
+ # system dependencies which don't get included by default and are then referenced by a package.
18
+ # This may seem counter-intuitive at first, but it is important to remember that when combining
19
+ # package use along with the use of other platform APIs smooths these sizes out as they will
20
+ # all be shared across all use cases.
21
+ # ####
22
+
7
23
# Our script is at our SmokeTest root, we want to look for the AppPackages folder
8
24
$PackagePath = $PSScriptRoot + " \AppPackages\"
9
25
$FilePattern = " SmokeTest_{0}_x86_bundle.msixupload"
26
+ $DirPattern = " SmokeTest_{0}_Test\SmokeTest_{0}_x86.msixbundle"
27
+
10
28
$BaselineName = $FilePattern -f " UWPBaseline"
29
+ $BaselineBundleName = $DirPattern -f " UWPBaseline"
11
30
$TempFolder = " ExplodedArchive"
31
+ $TempFolder2 = " ExplodedBundle"
12
32
13
33
function Expand-MsixUploadPackage {
14
34
param (
@@ -47,6 +67,34 @@ function Expand-MsixUploadPackage {
47
67
Pop-Location
48
68
}
49
69
70
+ function Expand-MsixBundlePackage {
71
+ param (
72
+ [string ]$PackageFile ,
73
+ [string ]$Destination
74
+ )
75
+
76
+ $ZipBundle = $PackageFile.Replace (" msixbundle" , " zip" )
77
+
78
+ Move-Item $PackageFile - Destination $ZipBundle
79
+
80
+ Expand-Archive $ZipBundle - DestinationPath $Destination
81
+
82
+ Move-Item $ZipBundle - Destination $PackageFile
83
+
84
+ Push-Location $Destination
85
+
86
+ $msix = (Get-ChildItem " *.msix" ).Name
87
+ $ZipMSIX = $msix.Replace (" msix" , " zip" )
88
+
89
+ Move-Item $msix - Destination $ZipMSIX
90
+
91
+ Expand-Archive $ZipMSIX - DestinationPath . - Force # Force here as we have some duplicate file names we don't really care about from parent archives
92
+
93
+ Remove-Item $ZipMSIX
94
+
95
+ Pop-Location
96
+ }
97
+
50
98
if (Test-Path $PackagePath )
51
99
{
52
100
Push-Location $PackagePath
@@ -55,35 +103,48 @@ if (Test-Path $PackagePath)
55
103
56
104
# TODO: Theoretically we could grab bits from the bin directory instead of having to expand each package, not sure about what we ignore though
57
105
Expand-MsixUploadPackage $BaselineName - Destination $TempFolder
106
+ Expand-MsixBundlePackage $BaselineBundleName - Destination $TempFolder2
58
107
59
108
# Get all the base file info only (grab stuff in directories but not the directories themselves)
60
109
$BaselineFiles = Get-ChildItem $TempFolder - Recurse - Attributes ! Directory - Exclude " SmokeTest*"
110
+ $BaselineFiles2 = Get-ChildItem $TempFolder2 - Recurse - Attributes ! Directory - Exclude " SmokeTest*"
61
111
$SmokeTestFiles = Get-ChildItem $TempFolder - Recurse - Attributes ! Directory - Include " SmokeTest*"
112
+ $SmokeTestFiles2 = Get-ChildItem $TempFolder2 - Recurse - Attributes ! Directory - Include " SmokeTest*"
62
113
63
114
$BaselineFootprint = ($BaselineFiles | Measure-Object - Property Length - sum).Sum + ($SmokeTestFiles | Measure-Object - Property Length - sum).Sum
64
- Write-Host (" Baseline Footprint: {0:n0} bytes" -f $BaselineFootprint )
115
+ $BaselineFootprint2 = ($BaselineFiles2 | Measure-Object - Property Length - sum).Sum + ($SmokeTestFiles2 | Measure-Object - Property Length - sum).Sum
116
+ Write-Host (" Baseline Max Footprint: {0:n0} bytes" -f $BaselineFootprint )
117
+ Write-Host (" Baseline Min Footprint: {0:n0} bytes" -f $BaselineFootprint2 )
65
118
Write-Host " -----------------------------------------"
66
119
67
120
$PackageList = Get-ChildItem " $PackagePath *.msixupload" - Exclude $BaselineName
68
121
69
122
# $i = 0
70
123
foreach ($Package in $PackageList )
71
124
{
125
+ # Extract the root package name between the initial '_'
126
+ $PackageShortName = ($Package.Name -split ' _' )[1 ]
127
+
72
128
# Write-Progress -Id 0 -Activity "Comparing Against Baseline..." -Status "Prepping Package" -PercentComplete (($i++ / $PackageList.count)*100) -CurrentOperation $Package.Name
73
129
74
130
# Make sure we've cleaned-up the last archive
75
131
Remove-Item $TempFolder - Recurse - Force
132
+ Remove-Item $TempFolder2 - Recurse - Force
76
133
77
134
# $ProgressPreference="SilentlyContinue"
78
135
Expand-MsixUploadPackage $Package.Name - Destination $TempFolder
136
+
137
+ # Also expand the final bundle based on the namespace name within the package.
138
+ Expand-MsixBundlePackage ($DirPattern -f $PackageShortName ) - Destination $TempFolder2
79
139
# $ProgressPreference="Continue"
80
140
81
141
[System.Collections.ArrayList ]$PackageFiles = Get-ChildItem $TempFolder - Recurse - Attributes ! Directory - Exclude " SmokeTest*"
82
142
$PackageSmokeTestFiles = Get-ChildItem $TempFolder - Recurse - Attributes ! Directory - Include " SmokeTest*"
143
+ [System.Collections.ArrayList ]$PackageFiles2 = Get-ChildItem $TempFolder2 - Recurse - Attributes ! Directory - Exclude " SmokeTest*"
144
+ $PackageSmokeTestFiles2 = Get-ChildItem $TempFolder2 - Recurse - Attributes ! Directory - Include " SmokeTest*"
83
145
84
- # TODO: Make function or regex better to extra package name more easily based on a template string at the top or something...
85
- $PackageShortName = $Package.Name.substring (10 , $Package.Name.Length - 32 )
86
- Write-Host (" {0} Additional Footprint: {1:n0} bytes" -f $PackageShortName , (($PackageFiles | Measure-Object - Property Length - sum).Sum + ($PackageSmokeTestFiles | Measure-Object - Property Length - sum).Sum - $BaselineFootprint ))
146
+ Write-Host (" {0} Additional Max Footprint: {1:n0} bytes" -f $PackageShortName , (($PackageFiles | Measure-Object - Property Length - sum).Sum + ($PackageSmokeTestFiles | Measure-Object - Property Length - sum).Sum - $BaselineFootprint ))
147
+ Write-Host (" {0} Additional Min Footprint: {1:n0} bytes" -f $PackageShortName , (($PackageFiles2 | Measure-Object - Property Length - sum).Sum + ($PackageSmokeTestFiles2 | Measure-Object - Property Length - sum).Sum - $BaselineFootprint2 ))
87
148
88
149
# Quick check on the base exe file/symbols differences
89
150
foreach ($file in $SmokeTestFiles )
@@ -132,6 +193,52 @@ if (Test-Path $PackagePath)
132
193
# TODO: Especially if we add comparison to the main branch, we should format as an actual table and colorize via VT: https://stackoverflow.com/a/49038815/8798708
133
194
134
195
# Write-Progress -Id 1 -ParentId 0 -Activity "Comparing Against Baseline..." -Completed
196
+ Write-Host " -----------------COMPILED----------------"
197
+
198
+ # Quick check on the base exe file/symbols differences
199
+ foreach ($file in $SmokeTestFiles2 )
200
+ {
201
+ $match = $null
202
+ $match = $PackageSmokeTestFiles2 | Where-Object {$_.Extension -eq $file.Extension }
203
+ if ($null -ne $match )
204
+ {
205
+ Write-Host (" App Diff: ({0}) = {1:n0}" -f $file.Extension , ($match.Length - $file.Length )) - ForegroundColor DarkCyan
206
+ }
207
+ }
208
+
209
+ # $j = 0
210
+ foreach ($file in $BaselineFiles2 )
211
+ {
212
+ # Write-Progress -Id 1 -ParentId 0 -Activity "Comparing Against Baseline..." -Status "Comparing Package" -PercentComplete (($j++ / $BaselineFiles.count)*100) -CurrentOperation $file.Name
213
+
214
+ $match = $null
215
+ $match = $PackageFiles2 | Where-Object {$_.Name -eq $file.Name }
216
+ if ($null -ne $match )
217
+ {
218
+ # File was in baseline, but has a different size
219
+ if ($match.Length -ne $file.Length )
220
+ {
221
+ Write-Host (" Size Diff: {0} = {1:n0}" -f $file.Name , ($match.Length - $file.Length )) - ForegroundColor Magenta
222
+ }
223
+
224
+ # Remove checked files (performance) and also remaining are new
225
+ $PackageFiles2.Remove ($match )
226
+ }
227
+ }
228
+
229
+ # List remaining (new) files to this package
230
+ foreach ($file in $PackageFiles2 )
231
+ {
232
+ if ($file.Name -match $PackageShortName )
233
+ {
234
+ Write-Host (" Lib (self): {0} = {1:n0}" -f $file.Name , $file.Length ) - ForegroundColor White
235
+ }
236
+ else
237
+ {
238
+ Write-Host (" Additional: {0} = {1:n0}" -f $file.Name , $file.Length ) - ForegroundColor Yellow
239
+ }
240
+ }
241
+
135
242
Write-Host " -----------------------------------------"
136
243
Write-Host
137
244
}
@@ -140,6 +247,7 @@ if (Test-Path $PackagePath)
140
247
141
248
# Clean-up
142
249
Remove-Item $TempFolder - Recurse - Force
250
+ Remove-Item $TempFolder2 - Recurse - Force
143
251
144
252
Pop-Location
145
253
}
0 commit comments