Skip to content

Commit 30eb1f3

Browse files
committed
v2.0.1-post2 [Extend .appxpack support to analysis commands]
### MAJOR - Extend `Get-AppxBackupInfo` to support .appxpack ZIP archives with full metadata extraction (archive manifest, contained packages/certificates, total size metrics) - Extend `Test-AppxPackageIntegrity` to validate .appxpack archive structure, manifest schema, package signatures, and certificate-to-package mappings - Extend `Test-AppxBackupCompatibility` to assess .appxpack compatibility including main package, all dependencies, and PowerShell version requirements - Add helper functions `Get-AppxpackArchiveInfo`, `Test-AppxpackArchiveIntegrity`, and `Test-AppxpackArchiveCompatibility` for internal ZIP archive handling - Implement unified file extension detection using `ZipPackagingConfiguration` for consistent .appxpack identification across module functions ### MINOR - Remove MIME type database handling entirely from packaging pipeline: MakeAppx automatically generates [Content_Types].xml with its own hardcoded MIME mappings, eliminating the need for maintaining a separate external database and dynamic generation logic - Remove `MimeTypes.json` configuration file and all MIME type validation/generation code from `New-AppxPackageInternal.ps1` (~160 lines of redundant logic) - Update `Get-AppxConfiguration` to remove `MimeTypes` from valid configuration names and validation rules - Update module manifest (AppxBackup.psd1) to remove `Config/MimeTypes.json` from file list and release notes - Update README.md to remove MimeTypes.json references from documentation and architecture diagrams - Replace Unicode emoji characters in `Test-AppxBackupCompatibility` output with plain ASCII headers (e.g., `[CHAR_128421]` → `===`) - Fix `switch` statement in `Test-AppxBackupCompatibility` OS detection by adding `break` statements after matches - Normalize spacing and indentation in `Get-AppxConfiguration` parameter validation - Add comprehensive logging and error handling for ZIP archive operations with fallback mechanisms
1 parent 3160eb5 commit 30eb1f3

File tree

8 files changed

+1126
-244
lines changed

8 files changed

+1126
-244
lines changed

AppxBackup.psd1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ Key Features:
125125
'Private\ConvertTo-SecureFilePath.ps1',
126126
'Private\Get-AppxConfiguration.ps1',
127127
'Private\Get-AppxDefault.ps1',
128-
'Config\MimeTypes.json',
129128
'Config\ToolConfiguration.json',
130129
'Config\WindowsReservedNames.json',
131130
'Config\PackageConfiguration.json',
@@ -169,7 +168,7 @@ Complete rewrite of AppxBackup module from 2016 deprecated implementation to mod
169168
MAJOR FEATURES:
170169
- ZIP-based dependency packaging (.appxpack) with structured metadata and orchestrated installation
171170
- Manifest parsing with multi-tier fallback strategies for namespace resolution
172-
- External JSON configuration system (MimeTypes, ToolConfiguration, ModuleDefaults, etc.)
171+
- External JSON configuration system (ToolConfiguration, ModuleDefaults, etc.)
173172
- Automatic certificate installation to Trusted Root store with privilege escalation fallback
174173
- SDK tool validation with intelligent fallback and comprehensive error diagnostics
175174
- Signature validation for backup archives using SignTool integration

Config/MimeTypes.json

Lines changed: 0 additions & 108 deletions
This file was deleted.

Private/Get-AppxConfiguration.ps1

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
- Support for all module configuration files
1515
1616
.PARAMETER ConfigName
17-
Name of the configuration file to load (without .json extension).
18-
Valid values: 'MimeTypes', 'ToolConfiguration', 'WindowsReservedNames',
19-
'PackageConfiguration', 'ModuleDefaults', 'ZipPackagingConfiguration'
17+
Name of the configuration file to load (without .json extension).
18+
Valid values: 'ToolConfiguration', 'WindowsReservedNames',
19+
'PackageConfiguration', 'ModuleDefaults', 'ZipPackagingConfiguration'
2020
2121
.PARAMETER Reload
2222
If specified, forces reload from disk even if cached.
@@ -37,8 +37,8 @@ function Get-AppxConfiguration {
3737
[OutputType([PSCustomObject])]
3838
param(
3939
[Parameter(Mandatory, Position = 0)]
40-
[ValidateSet('MimeTypes', 'ToolConfiguration', 'WindowsReservedNames', 'PackageConfiguration', 'ModuleDefaults', 'ZipPackagingConfiguration')]
41-
[string]$ConfigName,
40+
[ValidateSet('ToolConfiguration', 'WindowsReservedNames', 'PackageConfiguration', 'ModuleDefaults', 'ZipPackagingConfiguration')]
41+
[string]$ConfigName,
4242

4343
[Parameter()]
4444
[switch]$Reload
@@ -90,15 +90,6 @@ function Get-AppxConfiguration {
9090

9191
# Configuration-specific validation
9292
switch ($ConfigName) {
93-
'MimeTypes' {
94-
if (-not $config.mimeTypes) {
95-
throw "MimeTypes configuration missing 'mimeTypes' property"
96-
}
97-
if (-not $config.defaultContentType) {
98-
throw "MimeTypes configuration missing 'defaultContentType' property"
99-
}
100-
}
101-
10293
'ToolConfiguration' {
10394
if (-not $config.toolConfigurations) {
10495
throw "ToolConfiguration missing 'toolConfigurations' property"
@@ -119,7 +110,7 @@ function Get-AppxConfiguration {
119110
}
120111

121112
# Cache the configuration
122-
$script:ConfigCache[$ConfigName] = $config
113+
$script:ConfigCache[$ConfigName] = $config
123114

124115
return $config
125116
}

Private/New-AppxPackageInternal.ps1

Lines changed: 2 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -405,101 +405,11 @@ function New-AppxPackageInternal {
405405
}
406406

407407
# Verify critical files exist after copy
408-
$criticalFiles = @('AppxManifest.xml', '[Content_Types].xml')
408+
$criticalFiles = @('AppxManifest.xml')
409409
foreach ($critical in @($criticalFiles)) {
410410
$criticalPath = [System.IO.Path]::Combine($tempSourcePath, $critical)
411411
if (-not (Test-Path -LiteralPath $criticalPath)) {
412-
413-
# Special handling for [Content_Types].xml - generate if missing
414-
if ($critical -eq '[Content_Types].xml') {
415-
Write-AppxLog -Message "WARNING: [Content_Types].xml missing from source, generating comprehensive version" -Level 'Warning'
416-
417-
# Scan directory for all file extensions to include
418-
$extensions = @{}
419-
try {
420-
Get-ChildItem -LiteralPath $tempSourcePath -Recurse -File -ErrorAction SilentlyContinue | ForEach-Object {
421-
$ext = $_.Extension.TrimStart('.')
422-
if ($ext -and -not $extensions.ContainsKey($ext)) {
423-
$extensions[$ext] = $true
424-
}
425-
}
426-
Write-AppxLog -Message "Found $($extensions.Count) unique file extensions in package" -Level 'Debug'
427-
}
428-
catch {
429-
Write-AppxLog -Message "Could not scan extensions: $_ | Stack: $($_.ScriptStackTrace)" -Level 'Debug'
430-
}
431-
432-
# Build comprehensive Content_Types.xml with MIME types from external database
433-
$sb = [System.Text.StringBuilder]::new()
434-
[void]$sb.AppendLine('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>')
435-
[void]$sb.AppendLine('<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">')
436-
437-
# Load MIME type database from external configuration
438-
try {
439-
$mimeConfig = Get-AppxConfiguration -ConfigName 'MimeTypes'
440-
$mimeTypes = @{}
441-
442-
# Convert PSCustomObject properties to hashtable for easier lookup
443-
foreach ($property in @($mimeConfig.mimeTypes.PSObject.Properties)) {
444-
$mimeTypes[$property.Name] = $property.Value
445-
}
446-
447-
$defaultContentType = $mimeConfig.defaultContentType
448-
449-
Write-AppxLog -Message "Loaded $($mimeTypes.Count) MIME types from configuration" -Level 'Debug'
450-
}
451-
catch {
452-
# Fallback to minimal MIME types if configuration fails
453-
Write-AppxLog -Message "Failed to load MIME configuration, using fallback: $_ | Stack: $($_.ScriptStackTrace)" -Level 'Warning'
454-
455-
$mimeTypes = @{
456-
'xml' = 'application/xml'
457-
'dll' = 'application/x-msdownload'
458-
'exe' = 'application/x-msdownload'
459-
'png' = 'image/png'
460-
'jpg' = 'image/jpeg'
461-
'txt' = 'text/plain'
462-
}
463-
$defaultContentType = 'application/octet-stream'
464-
}
465-
466-
# Add default entries for all found extensions
467-
foreach ($ext in @($extensions.Keys)) {
468-
$contentType = if ($mimeTypes.ContainsKey($ext)) {
469-
$mimeTypes[$ext]
470-
} else {
471-
$defaultContentType
472-
}
473-
[void]$sb.AppendLine(" <Default Extension=`"$ext`" ContentType=`"$contentType`"/>")
474-
}
475-
476-
# Add standard entries that might not exist yet but are needed
477-
foreach ($kvp in $mimeTypes.GetEnumerator()) {
478-
if (-not $extensions.ContainsKey($kvp.Key)) {
479-
[void]$sb.AppendLine(" <Default Extension=`"$($kvp.Key)`" ContentType=`"$($kvp.Value)`"/>")
480-
}
481-
}
482-
483-
# Add APPX-specific overrides
484-
[void]$sb.AppendLine(' <Override PartName="/AppxManifest.xml" ContentType="application/vnd.ms-appx.manifest+xml"/>')
485-
[void]$sb.AppendLine(' <Override PartName="/AppxBlockMap.xml" ContentType="application/vnd.ms-appx.blockmap+xml"/>')
486-
[void]$sb.AppendLine(' <Override PartName="/AppxSignature.p7x" ContentType="application/vnd.ms-appx.signature"/>')
487-
[void]$sb.AppendLine('</Types>')
488-
489-
$contentTypesXml = $sb.ToString()
490-
491-
try {
492-
[System.IO.File]::WriteAllText($criticalPath, $contentTypesXml, [System.Text.UTF8Encoding]::new($false))
493-
Write-AppxLog -Message "Generated [Content_Types].xml with $($extensions.Count + $mimeTypes.Count) entries" -Level 'Debug'
494-
}
495-
catch {
496-
Write-AppxLog -Message "Failed to generate [Content_Types].xml: $_ | Stack: $($_.ScriptStackTrace)" -Level 'Error'
497-
throw "Failed to generate [Content_Types].xml: $_"
498-
}
499-
}
500-
else {
501-
throw "Critical file missing after copy: $critical (MakeAppx requires this file)"
502-
}
412+
throw "Critical file missing after copy: $critical (MakeAppx requires this file)"
503413
}
504414
}
505415
}

0 commit comments

Comments
 (0)