Skip to content

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

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugKeepOpenThe bot will ignore these and not auto-closeUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions