Skip to content

🥒 DLL Pickle

A PowerShell module that helps you get un-stuck from dependency version conflicts that can occur when connecting to multiple Microsoft online services.

GitHub top language Codacy Badge PRs Welcome PowerShell Gallery Version OpenSSF Best Practices

A stressed pickle trying to explain the problem in their code to a rubber duck.

🧑‍💻 Getting Started

Prerequisites

Any of the following PowerShell editions:

  • PowerShell on Linux, macOS, or Windows
  • Windows PowerShell 5.1

Installation

Install-Module DLLPickle -Scope CurrentUser

Or, if you use Microsoft.PowerShell.PSResourceGet, run:

Install-PSResource -Name DLLPickle

Using

All you have to do to use DLL Pickle is run the Import-DPLibrary command.

Import-Module DLLPickle
Import-DPLibrary

📝 Description

Let’s start with a few FAQs:

  • What does DLL Pickle actually do?

DLL Pickle pre-loads the newest version of the MSAL DLLs (and some of their transitive dependencies) that may be required by your other installed modules’ and scripts’ Connect-* cmdlets. (See the example below.)

  • Why does it need to do this?

It is common for PowerShell modules to ship with DLLs that provide precompiled functionality or dependencies. A PowerShell session cannot import two different versions of the same library (DLL). If a module imports one version of a DLL and then a different module attempts to import a second, newer version of that DLL, they will typically see an error that says, “an assembly with the same name is already loaded” and the second module will not be able to function.

  • Why don’t modules use Application Load Context (ALC) to solve this problem?

ALC can be very complex to implement and is only available in PowerShell 7. For these reasons, it is not commonly used in public modules.

  • Do these issues look familiar?

🧑‍💻 An Example Scenario

Numerous PowerShell modules include a dependency on the Microsoft Authentication Library (MSAL) for authenticating to Microsoft’s online services. The latest version of the MSAL is actively maintained in AzureAD/microsoft-authentication-library-for-dotnet. However, modules that depend on the MSAL libraries (such as Microsoft.Identity.Client.dll) all update their releases with different versions of MSAL on different schedules. This results in version conflicts that break authentication flows whenever you try to use multiple modules in one session. Examples of modules that can be affected by this include:

  • Az.Accounts
  • ExchangeOnlineManagement
  • Microsoft.Graph.Authentication
  • MicrosoftTeams
  • …and many more.

You could manually attempt to work around this by checking which version of the conflicting DLLs are used by each of your PowerShell modules and then connect first to whichever service module uses the newest version of the DLL. This works because of the “first one wins” rule and because the MSAL is designed to be backwards compatible. DLL Pickle handles this for you by automatically updating and releasing a new version of DLL Pickle whenever a new version of the MSAL is published. As long as you keep the DLL Pickle module up to date and run Import-DPLibrary before other modules, you should be able to connect to any Microsoft online service without DLL conflicts.

🥒 Using DLL Pickle

The easiest way to benefit from DLL Pickle is to import the module in your PowerShell profile before any other module or assembly is loaded. Just add the line Import-DPLibrary to your profile, save it, and start a new instance of PowerShell.

Alternatively, if you are starting work in a new PowerShell session in which you know you will be authenticating to multiple online services, you can run Import-DPLibrary at the beginning of your session and then proceed with connecting to Microsoft’s online services using their first party modules.

⚙️ Platform Caveats

  • PowerShell 7+ (Core, net8.0): Full support and best overall compatibility.
  • Windows PowerShell 5.1 (Desktop, net48): Supported with dependency-graph-based loading order, deterministic fallback for unresolved graph nodes, local assembly resolution fallback, and retry behavior for transitive assembly resolution.

If you need diagnostic details in Windows PowerShell 5.1, run:

Import-DPLibrary -ShowLoaderExceptions -Verbose

For detailed cmdlet guidance, see docs/DLLPickle/Import-DPLibrary.md.


📝 Additional Information

Versioning

This project follows the semantic versioning model. It also packages numerous dependencies that follow their own versioning. To maintain clarity, this project will follow SemVer standards and the following logic for version changes:

Major Versions

🏷️ 2.x.x.x - The major version will only change if there is a breaking change in the DLL Pickle project or if an MSAL dependency is released with a new major version (potentially indicating a breaking change).

Minor Versions

🏷️ X.1.X.X - The minor version will change if any of the following occur:

  • New features are added to the project
  • New MSAL library dependencies are added to the project
  • A new version of any associated library (DLL) is automatically updated within the project

Build Versions

🏷️ X.X.1.X - The build version will change if any of the following occur:

  • Minor refactoring for performance, error handling, or logging
  • Minor fixes for typos or formatting

External Documentation

All libraries tracked for pre-loading by DLL Pickle are maintained and documented by their own code owners. Please see each project accordingly: