gaelcolas / Sampler

Module template with build pipeline and examples, including DSC elements.
MIT License
172 stars 42 forks source link

Using CompleteSample generates duplicate `Prerelease` in module manifest #436

Closed crimsonread closed 1 year ago

crimsonread commented 1 year ago

Hello,

I'm the beginner for this module. When I run build.ps1 for the first time for the complete sample module, I encountered below error message and have no idea what I should look into.

/./build/Build_Module_ModuleBuilder/Build_ModuleOutput_ModuleBuilder C:\workfolder\test\output\RequiredModules\Sampler\0.116.5\tasks\Build-Module.ModuleBuilder.build.ps1:41

    Project Name               = ''
    Source Path                = 'C:\workfolder\test\source'
    Output Directory           = 'C:\workfolder\test\output'
    Release Notes path         = 'C:\workfolder\test\output\ReleaseNotes.md'
    Built Module Subdirectory  = 'C:\workfolder\test\output\module'
    Module Manifest Path (src) = 'C:\workfolder\test\source\.psd1'

ERROR: Cannot find path 'C:\workfolder\test\source.psd1' because it does not exist. At C:\workfolder\test\output\RequiredModules\Sampler\0.116.5\Sampler.psm1:491 char:27

johlju commented 1 year ago

Seems the module was not generated correctly since this path C:\workfolder\test\source\.psd1' should be 'C:\workfolder\test\source\test.psd1' and since that path is wrong the project name is empty but should say test.

What did you run to create the "test" module?

crimsonread commented 1 year ago

Seems the module was not generated correctly since this path C:\workfolder\test\source\.psd1' should be 'C:\workfolder\test\source\test.psd1' and since that path is wrong the project name is empty but should say test.

What did you run to create the "test" module?

I can see C:\workfolder\test\source\test.psd1 is existed. I ran below command to create test module.

New-SampleModule -DestinationPath C:\workfolder\ -ModuleDescription "test" -ModuleType CompleteSample -ModuleAuthor "duck" -ModuleName test -LicenseType MIT -ModuleVersion "0.1.0"

johlju commented 1 year ago

Could reproduce. If you look at the module manifest there are duplicate entries of Prerelease, remove one and it should build,

johlju commented 1 year ago

Let’s keep this open so we can track this bug.

crimsonread commented 1 year ago

Okay. Thanks!

SCOMnewbie commented 1 year ago

And just FYI, we have the same behavior if we choose moduletype SimpleModule as well.

johlju commented 1 year ago

There was different behavior on PowerShell and Windows PowerShell when creating the module manifest. So when the modify section that was meant to reuse the already present but commented Prerelease string it also ran the modify statement that adds the Prerelease for a module manifest that is created under Windows PowerShell resulting in two when creating a module under PowerShell 7.x. Now it will add a commented Perelease key and then next modify statement will remove the comment, making it work on all version of PowerShell (hopefully). 🙂

johlju commented 1 year ago

There is now a prerelease version out that fixes this issue. Will release a full release in a week or so (if no major issues are reported on the preview).