gaelcolas / Sampler

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

Newly created module cannot be built #443

Closed BenneMe closed 1 year ago

BenneMe commented 1 year ago

Problem description

Hi,

i've a problem when creating a new sampler module and try to built it. Unfortunately, I have little experience in using this module, but found the demos quite exciting. While testing the module I now came across this error The built process failes at the "BUILD MODULEOUTPUT MODULEBUILDER" task

===============================================================================
                        BUILD MODULEOUTPUT MODULEBUILDER
Build the Module based on its Build.psd1 definition
-------------------------------------------------------------------------------
  /./build/Build_Module_ModuleBuilder/Build_ModuleOutput_ModuleBuilder
  C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\tasks\Build-Module.ModuleBuilder.build.ps1:41

        Project Name               = ''
        Source Path                = 'C:\temp\SamplerTest\source'
        Output Directory           = 'C:\temp\SamplerTest\output'
        Release Notes path         = 'C:\temp\SamplerTest\output\ReleaseNotes.md'
        Built Module Subdirectory  = 'C:\temp\SamplerTest\output\module'
        Module Manifest Path (src) = 'C:\temp\SamplerTest\source\.psd1'
ERROR: Cannot find path 'C:\temp\SamplerTest\source\.psd1' because it does not exist.
At C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\Sampler.psm1:491 char:27
+ … oduleInfo = Import-PowerShellDataFile -Path $ModuleManifestPath -Erro …
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\tasks\Build-Module.ModuleBuilder.build.ps1:41 char:1
+ Task Build_ModuleOutput_ModuleBuilder {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Build FAILED. 5 tasks, 1 errors, 0 warnings 00:00:00.2136355
Import-PowerShellDataFile: Cannot find path 'C:\temp\SamplerTest\source\.psd1' because it does not exist.

Verbose logs

PS C:\temp\SamplerTest> .\build.ps1 -Verbose
[pre-build] Starting Build Init
VERBOSE: Populating RepositorySourceLocation property for module powershell-yaml.
VERBOSE: Loading module from path 'C:\temp\SamplerTest\output\RequiredModules\powershell-yaml\0.4.7\Load-Assemblies.ps1'.
VERBOSE: Loading module from path 'C:\temp\SamplerTest\output\RequiredModules\powershell-yaml\0.4.7\powershell-yaml.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module InvokeBuild.
VERBOSE: Loading module from path 'C:\temp\SamplerTest\output\RequiredModules\InvokeBuild\5.10.4\InvokeBuild.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module PSDepend.
VERBOSE: Loading module from path 'C:\temp\SamplerTest\output\RequiredModules\PSDepend\0.3.8\PSDepend.psm1'.
VERBOSE: Bootstrap completed. Handing back to InvokeBuild.
[build] Starting build with InvokeBuild.
VERBOSE: Populating RepositorySourceLocation property for module powershell-yaml.
VERBOSE: Loading module from path 'C:\temp\SamplerTest\output\RequiredModules\powershell-yaml\0.4.7\Load-Assemblies.ps1'.
VERBOSE: Loading module from path 'C:\temp\SamplerTest\output\RequiredModules\powershell-yaml\0.4.7\powershell-yaml.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module InvokeBuild.
VERBOSE: Loading module from path 'C:\temp\SamplerTest\output\RequiredModules\InvokeBuild\5.10.4\InvokeBuild.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module PSDepend.
VERBOSE: Loading module from path 'C:\temp\SamplerTest\output\RequiredModules\PSDepend\0.3.8\PSDepend.psm1'.
[build] Parsing defined tasks
[build] Loading Configuration from C:\temp\SamplerTest\build.yaml
VERBOSE: Loading module from path 'C:\temp\SamplerTest\output\RequiredModules\powershell-yaml\0.4.7\powershell-yaml.psd1'.
VERBOSE: Importing function 'ConvertFrom-Yaml'.
VERBOSE: Importing function 'ConvertTo-Yaml'.
VERBOSE: Importing alias 'cfy'.
VERBOSE: Importing alias 'cty'.
Importing tasks from module Sampler
VERBOSE: Loading module from path 'C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\Sampler.psd1'.
VERBOSE: Importing function 'Add-Sample'.
VERBOSE: Importing function 'Convert-SamplerHashtableToString'.
VERBOSE: Importing function 'Get-BuildVersion'.
VERBOSE: Importing function 'Get-BuiltModuleVersion'.
VERBOSE: Importing function 'Get-ClassBasedResourceName'.
VERBOSE: Importing function 'Get-CodeCoverageThreshold'.
VERBOSE: Importing function 'Get-MofSchemaName'.
VERBOSE: Importing function 'Get-OperatingSystemShortName'.
VERBOSE: Importing function 'Get-PesterOutputFileFileName'.
VERBOSE: Importing function 'Get-Psm1SchemaName'.
VERBOSE: Importing function 'Get-SamplerAbsolutePath'.
VERBOSE: Importing function 'Get-SamplerBuiltModuleBase'.
VERBOSE: Importing function 'Get-SamplerBuiltModuleManifest'.
VERBOSE: Importing function 'Get-SamplerCodeCoverageOutputFile'.
VERBOSE: Importing function 'Get-SamplerCodeCoverageOutputFileEncoding'.
VERBOSE: Importing function 'Get-SamplerModuleInfo'.
VERBOSE: Importing function 'Get-SamplerModuleRootPath'.
VERBOSE: Importing function 'Get-SamplerProjectName'.
VERBOSE: Importing function 'Get-SamplerSourcePath'.
VERBOSE: Importing function 'Invoke-SamplerGit'.
VERBOSE: Importing function 'Merge-JaCoCoReport'.
VERBOSE: Importing function 'New-SampleModule'.
VERBOSE: Importing function 'New-SamplerJaCoCoDocument'.
VERBOSE: Importing function 'New-SamplerPipeline'.
VERBOSE: Importing function 'Out-SamplerXml'.
VERBOSE: Importing function 'Set-SamplerPSModulePath'.
VERBOSE: Importing function 'Split-ModuleVersion'.
VERBOSE: Importing function 'Update-JaCoCoStatistic'.
VERBOSE: Importing alias 'Build-Module.ModuleBuilder.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'ChocolateyPackage.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'Clean.ModuleBuilder.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'Create_Changelog_Branch.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'Create_Release_Git_Tag.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'DeployAll.PSDeploy.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'DscResource.Test.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'generateHelp.PlatyPS.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'GuestConfig.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'Invoke-Pester.pester.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'JaCoCo.coverage.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'release.module.build.Sampler.ib.tasks'.
VERBOSE: Importing alias 'Set-SamplerTaskVariable'.
VERBOSE: Importing alias 'SetPsModulePath.build.Sampler.ib.tasks'.
         Loading Build-Module.ModuleBuilder.build.Sampler.ib.tasks...
         Loading ChocolateyPackage.build.Sampler.ib.tasks...
         Loading Clean.ModuleBuilder.build.Sampler.ib.tasks...
         Loading Create_Changelog_Branch.build.Sampler.ib.tasks...
         Loading Create_Release_Git_Tag.build.Sampler.ib.tasks...
         Loading DeployAll.PSDeploy.build.Sampler.ib.tasks...
         Loading DscResource.Test.build.Sampler.ib.tasks...
         Loading generateHelp.PlatyPS.build.Sampler.ib.tasks...
         Loading GuestConfig.build.Sampler.ib.tasks...
         Loading Invoke-Pester.pester.build.Sampler.ib.tasks...
         Loading JaCoCo.coverage.build.Sampler.ib.tasks...
         Loading release.module.build.Sampler.ib.tasks...
         Loading Set-SamplerTaskVariable...
         Loading SetPsModulePath.build.Sampler.ib.tasks...
Importing tasks from module Sampler.GitHubTasks
VERBOSE: Loading module from path 'C:\temp\SamplerTest\output\RequiredModules\Sampler.GitHubTasks\0.3.4\Sampler.GitHubTasks.psd1'.
VERBOSE: Importing function 'Get-GHOwnerRepoFromRemoteUrl'.
VERBOSE: Importing alias 'New-Release.GitHub.build.Sampler.GitHubTasks.ib.tasks'.
         Loading New-Release.GitHub.build.Sampler.GitHubTasks.ib.tasks...
Adding Workflow from configuration:
VERBOSE: Creating Build Workflow 'test' with tasks Pester_Tests_Stop_On_Fail, Pester_if_Code_Coverage_Under_Threshold.
  +-> test
VERBOSE: Creating Build Workflow 'build' with tasks Clean, Build_Module_ModuleBuilder, Build_NestedModules_ModuleBuilder, Create_changelog_release_output.
  +-> build
VERBOSE: Creating Build Workflow 'pack' with tasks build, package_module_nupkg.
  +-> pack
VERBOSE: Creating Build Workflow '.' with tasks build, test.
  +-> .
VERBOSE: Creating Build Workflow 'publish' with tasks publish_module_to_gallery, Publish_Release_To_GitHub.
  +-> publish
[build] Executing requested workflow: .
Build . C:\temp\SamplerTest\build.ps1
Redefined task '.'.

===============================================================================
                        CLEAN
Deleting the content of the Build Output folder, except ./modules
-------------------------------------------------------------------------------
  /./build/Clean
  C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\tasks\Clean.ModuleBuilder.build.ps1:16

Removing C:\temp\SamplerTest\output\* excluding RequiredModules
Done /./build/Clean 00:00:00.0079244

===============================================================================
                        BUILD MODULEOUTPUT MODULEBUILDER
Build the Module based on its Build.psd1 definition
-------------------------------------------------------------------------------
  /./build/Build_Module_ModuleBuilder/Build_ModuleOutput_ModuleBuilder
  C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\tasks\Build-Module.ModuleBuilder.build.ps1:41

        Project Name               = ''
        Source Path                = 'C:\temp\SamplerTest\source'
        Output Directory           = 'C:\temp\SamplerTest\output'
        Release Notes path         = 'C:\temp\SamplerTest\output\ReleaseNotes.md'
        Built Module Subdirectory  = 'C:\temp\SamplerTest\output\module'
        Module Manifest Path (src) = 'C:\temp\SamplerTest\source\.psd1'
ERROR: Cannot find path 'C:\temp\SamplerTest\source\.psd1' because it does not exist.
At C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\Sampler.psm1:491 char:27
+ … oduleInfo = Import-PowerShellDataFile -Path $ModuleManifestPath -Erro …
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\tasks\Build-Module.ModuleBuilder.build.ps1:41 char:1
+ Task Build_ModuleOutput_ModuleBuilder {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Build FAILED. 5 tasks, 1 errors, 0 warnings 00:00:00.2244738
Import-PowerShellDataFile: Cannot find path 'C:\temp\SamplerTest\source\.psd1' because it does not exist.

How to reproduce

Expected behavior

Built the module

Current behavior

===============================================================================
                        BUILD MODULEOUTPUT MODULEBUILDER
Build the Module based on its Build.psd1 definition
-------------------------------------------------------------------------------
  /./build/Build_Module_ModuleBuilder/Build_ModuleOutput_ModuleBuilder
  C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\tasks\Build-Module.ModuleBuilder.build.ps1:41

        Project Name               = ''
        Source Path                = 'C:\temp\SamplerTest\source'
        Output Directory           = 'C:\temp\SamplerTest\output'
        Release Notes path         = 'C:\temp\SamplerTest\output\ReleaseNotes.md'
        Built Module Subdirectory  = 'C:\temp\SamplerTest\output\module'
        Module Manifest Path (src) = 'C:\temp\SamplerTest\source\.psd1'
ERROR: Cannot find path 'C:\temp\SamplerTest\source\.psd1' because it does not exist.
At C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\Sampler.psm1:491 char:27
+ … oduleInfo = Import-PowerShellDataFile -Path $ModuleManifestPath -Erro …
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\tasks\Build-Module.ModuleBuilder.build.ps1:41 char:1
+ Task Build_ModuleOutput_ModuleBuilder {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Build FAILED. 5 tasks, 1 errors, 0 warnings 00:00:00.2136355
Import-PowerShellDataFile: Cannot find path 'C:\temp\SamplerTest\source\.psd1' because it does not exist.

Suggested solution

Unfortunately no

Operating system the target node is running

OsName               : Microsoft Windows 11 Pro
OsOperatingSystemSKU : 48
OsArchitecture       : 64-Bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 22621.1.amd64fre.ni_release.220506-1250
OsLanguage           : de-DE
OsMuiLanguages       : {de-DE}

PowerShell version and build the target node is running

Name                           Value
----                           -----
PSVersion                      7.3.7
PSEdition                      Core
GitCommitId                    7.3.7
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module version used

Name    Version Path
----    ------- ----
Sampler 0.116.5 C:\temp\SamplerTest\output\RequiredModules\Sampler\0.116.5\Sampler.psd1
johlju commented 1 year ago

You are hitting this bug https://github.com/gaelcolas/Sampler/issues/436, and it is fixed in the latest preview release of this module. I will try to push a new release this weekend.

BenneMe commented 1 year ago

Thanks for the information! I did not look closely at the issue in advance, sorry.

johlju commented 1 year ago

No worries, it was a good reminder for me to push the new release. 🙂 I'm pushing a new release as we speak so should be live in 30 minutes or so. 🙂 So please install the new release and then try again (in a new session so you import the new release). If you get any other issues please open new issues. Thanks for trying the module.