Resolve-MFModuleCase
SYNOPSIS
Fix module folder casing after a NuGet install so Get-Module and Import-Module can discover the module again
SYNTAX
Resolve-MFModuleCase [-ModuleName] <String> [[-ModuleFolder] <String[]>] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
DESCRIPTION
NuGet package IDs are enforced as all-lowercase, but PowerShell convention is PascalCase module names. When a module is installed from a NuGet v2+ feed on a case-sensitive (*NIX) filesystem, the folder is created in lowercase while the manifest keeps its PascalCase name. That folder/manifest mismatch effectively breaks discoverability (Get-Module, Import-Module). This function corrects it by renaming the module folder to match the manifest name.
How it works: Try and find a module folder based on a module name If module folders are found, for each one, try and find the latest Semver version If Semvers are identified, choose the latest If the latest version folder (As identified above) has a manifest, get the manifest name Case-Compare the manifest name with the folder name. If the name does not match, try and rename the folder On rename, sleep for 4 seconds, then proceed to other found locations and repeat if necessary
EXAMPLES
EXAMPLE 1
Resolve-MFModuleCase -ModuleName moduleforgecasetest -Verbose
DESCRIPTION
VERBOSE: ===========Executing Resolve-MFModuleCase=========== VERBOSE: Found 1 locations. Getting latest manifest VERBOSE: Checking folder C:\Users\example\Documents\PowerShell\Modules\moduleforgecasetest VERBOSE: Found latest version of: 1.0.1 VERBOSE: Found Manifest name with: ModuleForgeCaseTest WARNING: Case mismatch between module folder moduleforgecasetest and ModuleForgeCaseTest VERBOSE: Attempt to rename folder to manifest basename to correct for casing VERBOSE: Folder Rename attempted
PARAMETERS
-ModuleName
Name of the Module to resolve
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
-ModuleFolder
ModuleFolder to use. If you want to override the module locations manually, use this
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
OUTPUTS
[PSCustomObject] - Returns a result object per module location found, containing FolderFullName, FolderBaseName, ManifestName, RenameAttempt, and ManifestAndFolderMatch
NOTES
Author: Adrian Andersson