Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .cspell.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"Authenticode",
"davidanson",
"devcontainers",
"msix",
"msixbundle",
"netstandard",
"Nieto",
"Roamable",
"runneradmin",
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install AnyPackage.NuGet
run: Install-PSResource AnyPackage.NuGet -TrustRepository

- name: Download Microsoft.Msix.Utils NuGet Package
run: |
Import-Module AnyPackage.NuGet
Save-Package Microsoft.Msix.Utils

- name: Copy Microsoft.Msix.Utils.dll to src
run: Copy-Item ./Microsoft.Msix.Utils*/lib/netstandard2.0/Microsoft.Msix.Utils.dll ./src

- name: Upload module
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions src/AnyPackage.Appx.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
RequiredModules = @(
@{ ModuleName = 'AnyPackage'; ModuleVersion = '0.9.0' },
'Appx')
RequiredAssemblies = @('Microsoft.Msix.Utils.dll')
FunctionsToExport = @()
CmdletsToExport = @()
AliasesToExport = @()
Expand Down
27 changes: 25 additions & 2 deletions src/AnyPackage.Appx.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,34 @@
using namespace AnyPackage.Provider
using namespace Windows.Management.Deployment
using namespace Microsoft.Windows.Appx.PackageManager.Commands
using namespace Microsoft.Msix.Utils.AppxPackaging
using namespace System.IO

[PackageProvider('Appx')]
class AppxProvider : PackageProvider, IGetPackage, IUninstallPackage {
[PackageProvider('Appx', PackageByName = $false, FileExtensions = ('.appx', '.msix', '.msixbundle'))]
class AppxProvider : PackageProvider, IFindPackage, IGetPackage, IUninstallPackage {
[string[]] $Members = @()

[void] FindPackage([PackageRequest] $request) {
$appx = if ([Path]::GetExtension($request.Path) -eq '.msixbundle') {
[AppxBundleMetadata]::new($request.Path)
} else {
[AppxMetadata]::new($request.Path)
}

$metadata = @{ }
$properties = $appx |
Get-Member -Type Properties |
Select-Object -ExpandProperty Name

foreach ($member in $properties) {
$metadata[$member] = $appx.$member
}

$source = [PackageSourceInfo]::new($request.Path, $request.Path, $request.ProviderInfo)
$package = [PackageInfo]::new($appx.PackageName, $appx.Version.ToString(), $source, $appx.DisplayName, $null, $metadata, $request.ProviderInfo)
$request.WritePackage($package)
}

[void] GetPackage([PackageRequest] $request) {
$getAppxPackageParams = @{ Name = $request.Name }

Expand Down Expand Up @@ -48,10 +71,10 @@

$metadata = @{ }
foreach ($member in $this.Members) {
$metadata[$member] = $appx.$member

Check notice

Code scanning / PSScriptAnalyzer

Ignoring 'TypeNotFound' parse error on type 'AppxBundleMetadata'. Check if the specified type is correct. This can also be due the type not being known at parse time due to types imported by 'using' statements. Note

Ignoring 'TypeNotFound' parse error on type 'AppxBundleMetadata'. Check if the specified type is correct. This can also be due the type not being known at parse time due to types imported by 'using' statements.
}

$source = [PackageSourceInfo]::new($appx.InstallLocation, $appx.InstallLocation, $request.ProviderInfo)

Check notice

Code scanning / PSScriptAnalyzer

Ignoring 'TypeNotFound' parse error on type 'AppxMetadata'. Check if the specified type is correct. This can also be due the type not being known at parse time due to types imported by 'using' statements. Note

Ignoring 'TypeNotFound' parse error on type 'AppxMetadata'. Check if the specified type is correct. This can also be due the type not being known at parse time due to types imported by 'using' statements.
$package = [PackageInfo]::new($appx.Name, $appx.Version, $source, '', $null, $metadata, $request.ProviderInfo)
$request.WritePackage($package)
}
Expand Down