winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

README.md (3737B)


      1 # Windows Package Manager Configuration PowerShell Module
      2 
      3 The Windows Package Manager Configuration PowerShell Module is made up on two components
      4 
      5 1. The `Microsoft.WinGet.Configuration.Cmdlets` project which contains cmdlet implementations.
      6 2. The `Microsoft.WinGet.Configuration.Engine` project which contain the real logic for the cmdlets.
      7 
      8 ## Cmdlets
      9 - Get-WinGetConfiguration
     10 - Get-WinGetConfigurationDetails
     11 - Invoke-WinGetConfiguration
     12 - Start-WinGetConfiguration
     13 - Complete-WinGetConfiguration
     14 
     15 ## Syntax 
     16 ```
     17 Get-WinGetConfiguration -File <string> [<CommonParameters>]
     18 
     19 Get-WinGetConfigurationDetails -Set <PSConfigurationSet> [<CommonParameters>]
     20 
     21 Invoke-WinGetConfiguration -Set <PSConfigurationSet> [-AcceptConfigurationAgreements] [<CommonParameters>]
     22 
     23 Start-WinGetConfiguration -Set <PSConfigurationSet> [-AcceptConfigurationAgreements] [<CommonParameters>]
     24 
     25 Complete-WinGetConfiguration -ConfigurationJob <PSConfigurationJob> [<CommonParameters>]
     26 ```
     27 
     28 ## Prerequisites
     29 
     30 Minimum PowerShell 7 version: 7.2.8
     31 
     32 ## Telemetry
     33 Telemetry is enabled by default. To disable it one should set the POWERSHELL_TELEMETRY_OPTOUT env variable to “1”, “yes” or “true”.
     34 
     35 ## Building the PowerShell Module Locally
     36 After building the Microsoft.WinGet.Configuration.Cmdlets project, the `Microsoft.WinGet.Configuration` PowerShell module can be found in the output directory in the `PowerShell` folder. For example if you built the project as x64 release, you should expect to find the module files in `$(SolutionDirectory)/src/x64/Release/PowerShell`.
     37 
     38 
     39 ## Adding a new cmdlet
     40 In order to avoid [assembly dependency conflicts](https://learn.microsoft.com/en-us/powershell/scripting/dev-cross-plat/resolving-dependency-conflicts?view=powershell-7.3) this project uses a custom `AssemblyLoadContext` that load all dependencies.
     41 
     42 Microsoft.WinGet.Configuration.Cmdlets.dll is the binary that gets loaded when the module is imported. When Microsoft.WinGet.Configuration.Engine.dll is getting loaded the resolving handler use the custom ALC to load it. Then all the dependencies of that binary will be loaded using that custom context.
     43 
     44 The dependencies are laid out in two directories: `DirectDependencies` and `SharedDependencies`. The resolving handler looks for binaries under `DirectDependencies` and uses the custom ALC to load them. The custom ALC load any binaries in `DirectDependencies` and `SharedDependencies`.
     45 
     46 Exception: WinRT.Runtime.dll doesn't support getting loaded in multiple times in the same process, because it affects static state in the CLR itself. We special case it to get loaded in by the default loader.
     47 
     48 ### Current layout.
     49 ```
     50 Microsoft.WinGet.Configuration.Cmdlets.dll
     51 DirectDependencies\Microsoft.WinGet.Configuration.Engine.dll
     52 SharedDependencies\Microsoft.Management.Configuration.Processor.dll
     53 SharedDependencies\Microsoft.Windows.SDK.NET.dll
     54 SharedDependencies\WinRT.Runtime.dll
     55 SharedDependencies\x64\Microsoft.Management.Configuration.dll
     56 SharedDependencies\x64\Microsoft.Management.Configuration.Projection.dll
     57 SharedDependencies\x86\Microsoft.Management.Configuration.dll
     58 SharedDependencies\x86\Microsoft.Management.Configuration.Projection.dll
     59 ```
     60 If the new cmdlet introduces a new dependency, please make sure to add it to the proper location in the AfterBuild tasks in Microsoft.WinGet.Configuration.Cmdlets.csproj.
     61 
     62 ### Dependency graph
     63 ```mermaid
     64 graph TD;
     65     subgraph DF[Default Loader]
     66         DF_1[Cmdlets.dll]
     67         DF_2[WinRT.Runtime.dll]
     68     end
     69     subgraph ALC[Custom ALC]
     70         ALC_1[Engine.dll]
     71         ALC_2[Other dependencies]
     72         ALC_1--> ALC_2
     73     end
     74 
     75 DF_1--> ALC_1
     76 ALC_1 --> DF_2
     77 ```