KEMBAR78
Import-Module -Prefix '' on a module with a Default Prefix defined does not remove the prefix · Issue #16936 · PowerShell/PowerShell · GitHub
Skip to content

Import-Module -Prefix '' on a module with a Default Prefix defined does not remove the prefix #16936

@JustinGrote

Description

@JustinGrote

Prerequisites

Steps to reproduce

  1. Make a module, and set Prefix to 'Test'
  2. Import-Module MyTestModule -Prefix ''
  3. All commands will still have test prefix

This is because the prefix test checks for IsNullOrEmpty instead of just null.

            bool usePrefix = !string.IsNullOrEmpty(prefix);

As such it is impossible to override the prefix which affects the ability to write pester tests on modules, etc. and use the original function names so that things like references and go to definition work in IDEs like vscode.

Workaround

Make a secondary manifest that references the same module but does not have the prefix specified.

Expected behavior

Commands without prefix

Actual behavior

Commands have default prefix

Error details

No response

Environment data

PS 7.2.1

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesWG-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions