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
38 changes: 38 additions & 0 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@ For usage guidance, see [README.md](README.md) and [docs/index.md](docs/index.md
| **Major** (X.y.z) | Manual review | Explicit maintainer approval |
| **Upstream PowerShell module drift** | Candidate PR or issue | Upstream Compatibility workflow |

## Versioning

DLLPickle follows [Semantic Versioning](https://semver.org/) (`MAJOR.MINOR.PATCH`).
Releases are cut automatically by the **Release-and-Publish** workflow, which
derives the bump **solely from the [Conventional Commit](https://www.conventionalcommits.org/)
prefixes** of the commits since the last tag (see
[`.github/ci-scripts/Get-VersionBump.ps1`](.github/ci-scripts/Get-VersionBump.ps1)):

| Bump | Commit prefix |
| ---- | ------------- |
| **MAJOR** (`X.y.z`) | `BREAKING CHANGE:`, `breaking:`, or `major-release` |
| **MINOR** (`x.Y.z`) | `feat:` (or `minor:`) |
| **PATCH** (`x.y.Z`) | `fix:`, `perf:`, `refactor:`, `security:`, or `chore:` |

The bump is decided by the commit prefix alone — there is **no** separate
detection of dependency or MSAL version changes. Label dependency-update PRs
accordingly: the automated MSAL / identity-library bumps that are the module's
core purpose should land as `feat:` so they produce a **minor** release, and a
bundled-library **major** jump should be committed as a breaking change.

A new PowerShell Gallery version is published **only** when a change affects the
published module bundle (`src/DLLPickle/**` or the bundled package set). CI-,
docs-, policy-, and tooling-only changes do not trigger a release. See
[CHANGELOG.md](CHANGELOG.md) for the released history.

## Upstream Compatibility Automation

Dependabot tracks NuGet package releases, but DLLPickle also tracks the DLLs
Expand Down Expand Up @@ -59,6 +84,19 @@ candidate generation, restore, build, and issue reproduction tests pass.
| `Microsoft.IdentityModel.Tokens` | `8.*` | Token validation/processing |
| `System.IdentityModel.Tokens.Jwt` | `8.*` | JWT handlers |

### Upstream package documentation

The libraries DLLPickle tracks for preloading are maintained and documented by
their own code owners:

- [Microsoft.Identity.Abstractions](https://www.nuget.org/packages/Microsoft.Identity.Abstractions)
- [Microsoft.Identity.Client](https://www.nuget.org/packages/Microsoft.Identity.Client)
- [Microsoft.IdentityModel.Abstractions](https://www.nuget.org/packages/Microsoft.IdentityModel.Abstractions)
- [Microsoft.IdentityModel.JsonWebTokens](https://www.nuget.org/packages/Microsoft.IdentityModel.JsonWebTokens)
- [Microsoft.IdentityModel.Logging](https://www.nuget.org/packages/Microsoft.IdentityModel.Logging)
- [Microsoft.IdentityModel.Tokens](https://www.nuget.org/packages/Microsoft.IdentityModel.Tokens)
- [System.IdentityModel.Tokens.Jwt](https://www.nuget.org/packages/System.IdentityModel.Tokens.Jwt)

## Exact Pin Rationale

- Exact pins are used for the MSAL managed family (`Microsoft.Identity.Client`
Expand Down
251 changes: 81 additions & 170 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,170 +1,81 @@
<!-- markdownlint-configure-file { "MD033": false } -->
# 🥒 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.

<!-- badges-start -->
![GitHub top language](https://img.shields.io/github/languages/top/SamErde/DLLPickle)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ae92f0d929de494690e712b68fb3b52c)](https://app.codacy.com/gh/SamErde/DLLPickle/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![PowerShell Gallery Version](https://img.shields.io/powershellgallery/v/DLLPickle?include_prereleases)](https://powershellgallery.com/packages/DLLPickle)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/11450/badge)](https://www.bestpractices.dev/projects/11450)
<!-- badges-end -->

<img src="https://raw.githubusercontent.com/SamErde/DLLPickle/main/assets/dllpickle.png" alt="A stressed pickle trying to explain the problem in their code to a rubber duck." width="400" />

## 🧑‍💻 Getting Started

### Prerequisites

PowerShell 7.4 or later on Linux, macOS, or Windows.

### Installation

```powershell
Install-Module DLLPickle -Scope CurrentUser
```

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

```powershell
Install-PSResource -Name DLLPickle
```

### Using

Import the module, then run `Import-DPLibrary` before connecting to service modules.

```powershell
Import-Module DLLPickle
Import-DPLibrary
```

### Core Commands

DLLPickle currently exports the following commands:

- `Import-DPLibrary`: preload DLLPickle-managed assemblies in dependency-aware order.
- `Get-DPConfig`: view your current DLLPickle configuration.
- `Set-DPConfig`: update DLLPickle configuration (for example, show logo, skip libraries).
- `Find-DLLInPSModulePath`: inspect module paths for matching DLLs.
- `Get-ModuleImportCandidate`: determine which installed module version would import.
- `Get-ModulesWithDependency`: list installed modules that package a target dependency.
- `Get-ModulesWithVersionSortedIdentityClient`: compare modules by packaged `Microsoft.Identity.Client.dll` version.

For complete syntax and examples, see:

- [docs index](docs/index.md)
- [module command reference](docs/DLLPickle.md)

---

## 📝 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?**

### Related GitHub Issues

- [Connect-MgGraph fails after Connect-ExchangeOnline](https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/3394)
- [UUF Customer feedback: Get-EntraExtensionProperty error](https://github.com/microsoftgraph/entra-powershell/issues/1258) (Assembly with same name is already loaded)
- [Assembly with same name is already loaded](https://github.com/microsoftgraph/entra-powershell/issues/1083)
- [Design entra-powershell with ALC bridge pattern for a more robust assembly load handling](https://github.com/microsoftgraph/entra-powershell/issues/1242)
- [Implement proper assembly isolation to play nice with vscode-powershell](https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2978)
- [Conflict with the .Net dll of the Az module PowerShell/vscode-powershell#3012](https://github.com/PowerShell/vscode-powershell/issues/3012)
- [Unable to load Az modules - Assembly with same name is already loaded PowerShell/vscode-powershell#4727](https://github.com/PowerShell/vscode-powershell/issues/4727)

### 🧑‍💻 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](https://github.com/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 Support

- **PowerShell 7.4+ (Core, net8.0):** Fully supported target runtime.

If you need diagnostic details, run:

```powershell
Import-DPLibrary -ShowLoaderExceptions -Verbose
```

For detailed cmdlet guidance, see [docs/DLLPickle/Import-DPLibrary.md](docs/DLLPickle/Import-DPLibrary.md).

For deeper compatibility and dependency details, see [DEPENDENCIES.md](DEPENDENCIES.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:

- [Microsoft.Identity.Abstractions](https://www.nuget.org/packages/Microsoft.Identity.Abstractions)
- [Microsoft.Identity.Client](https://www.nuget.org/packages/Microsoft.Identity.Client)
- [Microsoft.IdentityModel.Abstractions](https://www.nuget.org/packages/Microsoft.IdentityModel.Abstractions)
- [Microsoft.IdentityModel.JsonWebTokens](https://www.nuget.org/packages/Microsoft.IdentityModel.JsonWebTokens)
- [Microsoft.IdentityModel.Logging](https://www.nuget.org/packages/Microsoft.IdentityModel.Logging)
- [Microsoft.IdentityModel.Tokens](https://www.nuget.org/packages/Microsoft.IdentityModel.Tokens)
- [System.IdentityModel.Tokens.Jwt](https://www.nuget.org/packages/System.IdentityModel.Tokens.Jwt)

## Project Documentation Map

- User guide and overview: [docs/index.md](docs/index.md)
- Deep technical explanation: [docs/Deep-Dive.md](docs/Deep-Dive.md)
- Full command reference: [docs/DLLPickle.md](docs/DLLPickle.md)
- Changelog and active work: [CHANGELOG.md](CHANGELOG.md)
- Architecture blueprint and planned enhancements: [docs/Architecture.md](docs/Architecture.md)
- Contribution workflow: [.github/CONTRIBUTING.md](.github/CONTRIBUTING.md)
- Dependency and supply chain policy: [DEPENDENCIES.md](DEPENDENCIES.md)
- Security vulnerability reporting: [SECURITY.md](SECURITY.md)
<!-- markdownlint-configure-file { "MD033": false } -->
# 🥒 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.

<!-- badges-start -->
![GitHub top language](https://img.shields.io/github/languages/top/SamErde/DLLPickle)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ae92f0d929de494690e712b68fb3b52c)](https://app.codacy.com/gh/SamErde/DLLPickle/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![PowerShell Gallery Version](https://img.shields.io/powershellgallery/v/DLLPickle?include_prereleases)](https://powershellgallery.com/packages/DLLPickle)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/11450/badge)](https://www.bestpractices.dev/projects/11450)
<!-- badges-end -->

<img src="https://raw.githubusercontent.com/SamErde/DLLPickle/main/assets/dllpickle.png" alt="A stressed pickle trying to explain the problem in their code to a rubber duck." width="400" />

## 🧑‍💻 Getting Started

### Prerequisites

PowerShell 7.4 or later on Linux, macOS, or Windows.

### Installation

```powershell
Install-Module DLLPickle -Scope CurrentUser
```

Or, with **Microsoft.PowerShell.PSResourceGet**:

```powershell
Install-PSResource -Name DLLPickle
```

### Using

Import DLL Pickle and run `Import-DPLibrary` **before** connecting to other service modules — ideally as the first thing in your PowerShell profile, so it loads first in every session.

```powershell
Import-Module DLLPickle
Import-DPLibrary
```

For diagnostic detail, add `-ShowLoaderExceptions -Verbose`.

### Commands

**Primary:**

- `Import-DPLibrary` — preload DLLPickle-managed assemblies in dependency-aware order.
- `Import-DPBaseProfile` — preload, then import the validated base-profile modules (Exchange Online, Teams, Graph, Az.Accounts) in a known-good order.
- `Test-DPLibraryConflict` — report known-incompatible module pairs loaded in the current session, with the workaround.
- `Get-DPConfig` / `Set-DPConfig` — view or change configuration (for example, show logo, skip libraries).

**Inspection helpers:**

- `Find-DLLInPSModulePath` — find DLLs across module paths, filtered by product metadata.
- `Get-ModuleImportCandidate` — show which installed module version would import.
- `Get-ModulesWithDependency` — list installed modules that package a given dependency.
- `Get-ModulesWithVersionSortedIdentityClient` — compare modules by packaged `Microsoft.Identity.Client.dll` version.

Full syntax and examples: [docs index](docs/index.md) · [command reference](docs/DLLPickle.md).

## 🥒 How It Works

Many PowerShell modules — Az, Exchange Online, Microsoft Graph, Teams, and more — bundle their own copy of the Microsoft Authentication Library (MSAL) and related DLLs. A single PowerShell session can only load **one** version of a given DLL, so when two modules ship different versions you hit *"an assembly with the same name is already loaded"* and authentication breaks.

DLL Pickle preloads a current, compatible set of these assemblies **first**, so the "first one wins" rule works in your favor and the modules you load afterward reuse what's already there. A new DLL Pickle release is published automatically whenever a new MSAL version ships — so keep it updated and load it first.

For the full explanation (and the real-world issues that motivated it), read the [Deep Dive](docs/Deep-Dive.md). The supported platform is **PowerShell 7.4+ (Core, net8.0)**; compatibility, versioning, and dependency details live in [DEPENDENCIES.md](DEPENDENCIES.md).

## 📚 Documentation Map

- User guide and overview: [docs/index.md](docs/index.md)
- Deep technical explanation: [docs/Deep-Dive.md](docs/Deep-Dive.md)
- Troubleshooting and issue reproduction: [docs/Troubleshooting.md](docs/Troubleshooting.md)
- Full command reference: [docs/DLLPickle.md](docs/DLLPickle.md)
- Changelog and active work: [CHANGELOG.md](CHANGELOG.md)
- Architecture blueprint and planned enhancements: [docs/Architecture.md](docs/Architecture.md)
- Dependency, versioning, and supply-chain policy: [DEPENDENCIES.md](DEPENDENCIES.md)
- Contribution workflow: [.github/CONTRIBUTING.md](.github/CONTRIBUTING.md)
- Security vulnerability reporting: [SECURITY.md](SECURITY.md)
8 changes: 8 additions & 0 deletions docs/DLLPickle.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ Gets modules and sorts them by packaged `Microsoft.Identity.Client.dll` version.

Imports DLLPickle dependency libraries.

### [Import-DPBaseProfile](DLLPickle/Import-DPBaseProfile.md)

Runs `Import-DPLibrary` and imports the validated base-profile modules (Exchange Online, Microsoft Teams, Microsoft Graph, and Az.Accounts) in a known-good order.

### Test-DPLibraryConflict

Reports known-incompatible module combinations loaded in the current session (for example the Az.Storage + ExchangeOnlineManagement OData conflict, issue #174), with the reason and the separate-process workaround. _(The per-command help page is generated during the in-progress `Microsoft.PowerShell.PlatyPS` migration.)_

## Archived Commands

The following pages are retained for historical reference and migration guidance.
Expand Down
13 changes: 13 additions & 0 deletions docs/Deep-Dive.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ load errors.
DLLPickle addresses this by loading a compatible set of identity-related
assemblies before other modules attempt their own assembly loads.

## Related Issues

This class of conflict is widely reported across Microsoft's first-party
PowerShell modules:

- [Connect-MgGraph fails after Connect-ExchangeOnline](https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/3394)
- [UUF Customer feedback: Get-EntraExtensionProperty error](https://github.com/microsoftgraph/entra-powershell/issues/1258) (Assembly with same name is already loaded)
- [Assembly with same name is already loaded](https://github.com/microsoftgraph/entra-powershell/issues/1083)
- [Design entra-powershell with ALC bridge pattern for more robust assembly load handling](https://github.com/microsoftgraph/entra-powershell/issues/1242)
- [Implement proper assembly isolation to play nice with vscode-powershell](https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2978)
- [Conflict with the .NET DLL of the Az module (vscode-powershell#3012)](https://github.com/PowerShell/vscode-powershell/issues/3012)
- [Unable to load Az modules — Assembly with same name is already loaded (vscode-powershell#4727)](https://github.com/PowerShell/vscode-powershell/issues/4727)

## How DLLPickle Works

`Import-DPLibrary` loads DLLs from the module's packaged `bin` folder that
Expand Down
Loading
Loading