PoshCode / ModuleBuilder

A PowerShell Module to help scripters write, version, sign, package, and publish.
MIT License
445 stars 54 forks source link

Error when invoking Build-Module again #117

Closed danielniccoli closed 1 year ago

danielniccoli commented 1 year ago

Build-Module throws an error when it is invoked again.

PS C:\temp\modb> dotnet new PSModuleBuilder -o MyNewModule
The template "PowerShell Module with ModuleBuilder" was created successfully.
PS C:\temp\modb> cd .\MyNewModule\
PS C:\temp\modb\MyNewModule> Build-Module
PS C:\temp\modb\MyNewModule> dir .\Output\

    Directory: C:\temp\modb\MyNewModule\Output

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          19.10.2022    20:03           4514 MyNewModule.psd1

PS C:\temp\modb\MyNewModule> Build-Module
Write-Error: The specified module 'C:\temp\modb\MyNewModule' was not found. Update the Name parameter to point to a valid path, and then try again.

Exception: Unresolvable problems in module manifest: 'C:\temp\modb\MyNewModule'

PS C:\temp\modb\MyNewModule> get-module ModuleBuilder

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     1.7.0                 ModuleBuilder                       {Build-Module, Convert-CodeCoverage, Convert-LineNumber, build}
Jaykul commented 1 year ago

This has been fixed, and cannot be reproduced with the template now.

It seems you either removed "VersionedOutputDirectory" from your build.psd1 or did not have a build.psd1

Basically, this happened because your output ended up in Output\MyNewModule.psd1 instead of in Output\MyNewModule\1.0.0\MyNewModule.psd1 -- where it should come out if you just use the template as-is.

When the build.psd1 is not present, the fact that you have two copies of MyNewModule.psd1 means that ModuleBuilder can't tell which one is the base.