patriksvensson / cupboard

A framework for provisioning local environments to a desired state, using the .NET SDK.
MIT License
762 stars 19 forks source link

AppX Packages provider #1

Open patriksvensson opened 3 years ago

jetersen commented 3 years ago

Some question on this.

This provider could use the powershell provider and in purely in Windows PowerShell flavor since AppX module is not compatible with PowerShell 7. edit: Right one provider cannot talk to another 😓

I don't know of any C# library for accessing appx info.

Since this would most like map to powershell.exe -Command Add-AppxPackage and Get-AppxPackage for getting the state. edit: This would indeed be useful to ensure WinGet appx is installed.

Name              : Microsoft.Winget.Source
Publisher         : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture      : Neutral
ResourceId        :
Version           : 2021.916.2041.763
PackageFullName   : Microsoft.Winget.Source_2021.916.2041.763_neutral__8wekyb3d8bbwe
InstallLocation   : C:\Program Files\WindowsApps\Microsoft.Winget.Source_2021.916.2041.763_neutral__8wekyb3d8bbwe
IsFramework       : False
PackageFamilyName : Microsoft.Winget.Source_8wekyb3d8bbwe
PublisherId       : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle          : False
IsDevelopmentMode : False
NonRemovable      : False
IsPartiallyStaged : False
SignatureKind     : Store
Status            : Ok
patriksvensson commented 3 years ago

There is the Package deployment API and the Package query API which I think would be the preferable approach for this.

As an initial approach, I see nothing wrong with shelling out to PowerShell though.

jetersen commented 3 years ago

Seems simple enough :) https://github.com/microsoft/Windows-classic-samples/blob/main/Samples/PackageManagerAddPackage/cs/AddPackageSample.cs