psake / PowerShellBuild

Common build tasks for psake and Invoke-Build that build and test PowerShell modules
MIT License
134 stars 24 forks source link

CompileModule = $true fails on Classes #66

Open TrisBits opened 1 year ago

TrisBits commented 1 year ago

When executing a build using $PSBPreference.Build.CompileModule = $true on a base Stucco template, I receive an error on the Task GENERATEMARKDOWN. However, if I use $PSBPreference.Build.CompileModule = $false the build will succeed.

Expected Behavior

The build of a monolithic PSM1 should not produce errors regarding Classes.

Current Behavior

I receive the following error:

Error: 2022-12-14 9:19:54 PM: At C:\Temp\ModuleNew\Output\ModuleNew\0.1.0\ModuleNew.psm1:31 char:14 + … classes = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -Child … + ~~~~~~~~~~~~~ [<<==>>] Exception: Cannot find path 'C:\Temp\ModuleNew\Output\ModuleNew\0.1.0\Classes\' because it does not exist.

Steps to Reproduce (for bugs)

  1. Create a new module with Stucco
  2. Set psakeFile parameter $PSBPreference.Build.CompileModule = $true
  3. Execute .\build.ps1 from a pwsh terminal

Context

This issue prevents me from being able to build a module.

Your Environment

HeyItsGilbert commented 3 months ago

It sounds like your C:\Temp\ModuleNew\ModuleNew\ModuleNew.psm1 has code that is loading from that directory. If you're compiling you'll want to edit your psm1 file to account for that.