Skip to content

Added programmatic generation capabilities to the module build process#402

Open
Foggy2 wants to merge 7 commits intoSCRT-HQ:mainfrom
Foggy2:programmatic-generation
Open

Added programmatic generation capabilities to the module build process#402
Foggy2 wants to merge 7 commits intoSCRT-HQ:mainfrom
Foggy2:programmatic-generation

Conversation

@Foggy2
Copy link
Contributor

@Foggy2 Foggy2 commented Jun 7, 2025

Hi @scrthq & @jgeron-suhsd

I have been working on some other changes that require the ability to programmatically generate some classes and functions at build time.

So I have put this together to support that, but also support any future work that may make use of programmatic generation of the module content.

As a high level explanation, I have made the following changes:

  • Added additional tasks Download and Generate to the PSAKE build process.
    • Download contains the existing code to download the NuGet dependencies, simply moved from the Compile task.
    • Generate contains the new programmatic generation functionality.
  • The Generate task generates content by executing all .ps1 files found in the ci\templates directory. These files are expected to return either String or Hashtable output that contains the generated PowerShell code. The generated code will be written to the corresponding file in the source directory. See the ci\templates\README.md file for a more detailed explanation of the functionality.
  • The Compile task now captures the source code from the Class, Private, Public and Module source code folders.
  • The existing module initialization code that is injected by the Compile task has been split and moved into two files:
    • The dynamic alias logic has been moved into the templates\Module\Aliases.ps1 template file.
    • The static module initialization logic has been moved into the Module\Initialization.ps1 file.

I have made a few design decisions with this so I am very conscious of getting some feedback. Let me know your thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants