PSMake
PSMake copied to clipboard
PSMake is an all-in-one project management and lifecycle toolset for PowerShell.
PSMake
PowerShell Project Management and Lifecycle

PSMake is an all-in-one project management and lifecycle toolset for PowerShell.
❗NOTICE ❗
Please see the NOTICE regarding copyright and ownership information as it highly affects the LICENSE.
Traditional PowerShell Module Development Problems
- Only a Manifest (psd1) and module file (psm1) with all logic in one file
- No seperation of development and production - Unit Tests distributed to users? 😬
- Separating the functions into individual ps1 files and dotsourcing them creates a nightmare for code signing
- Code signing breaks every time there is a change and PowerShell refuses to import the module.
- Getting around these issues is up to each project to create their own solutions making every project a unique with no known conventions - You can't automate without standards and conventions
Highlights
Creates the standards and conventions lacking the traditional PowerShell development without being too rigid. Conventions and behaviors can be changed per project without breaking known usages of PSMake.
- Project is made of seperate function scripts (ps1 files) within the functions folder allowing for custom scoping - no more implicit global scope
- Unit test files are in a seperate tests folder that run on the development version of the module. No more distributing the unit tests to users
- Generates a distributable version of the module in a flexible, easy-to-read build manifest file (build.psd1)
- Capable of code signing output files for a given target (Debug, Release, Prerelease).
- Able to scaffold new projects without any changes necessary - turn-key ready.
Who should use this?
Any PowerShell script project should use this whether simple or complex. Binary modules written in C# can also use it, but may not be necessary.
Examples
Create a new project
PS> PSMake template MyProjectName
Build release version of the module
PS> PSMake # Default parameters are 'build Release'
PS> PSMake build Release
Build Debug version of the module
PS> PSMake build Debug
Run unit tests on the module
PS> PSMake test
Run unit tests, but pass a parameter for reports (code coverage and test result xml files)
PS> PSMake test reports
Clean the project (removes the distribution (dist) folder containing the generated module)
PS> PSMake clean
Publish the release version of the module
PS> PSMake publish 'Your-NuGet-API-Key'
Customizing the project workflow - build.psd1
PSD1 files are a text document containing a PowerShell hashtable (@{}
) with keys being set equal to a value.
The build.psd1
file is a PowerShell hashtable with expected keys. Some keys are required while others are optional with an implicit default value. A build.psd1
can be generated using the Create a new Project example. The generated file contains all available keys and documentation on its behavior and expected type.
The workflow keys are Build
, Clean
, Test
, and Publish
with each assigned to a scriptblock ({}
) literal. This scriptblock is called in the scope of the PSMake module giving access to the special commands that express the build intent.
Special Commands
Command | Description | Example |
AddType | Adds a C# file using Add-Type to the psm1 file |
|
CodeSign | Code signs the returns files from the given scriptblock |
|
Collate | Brings multiple function ps1 files into a single psm1 file |
|
CopyDirectory | Copies directories into the distribution folder |
|
CopyFiles | Copies files into the distribution folder |
|
CreateDirectory | Creates a directory in the distribution folder |
|
CustomCode | Adds codes to the generated psm1 file in the distribution folder |
|
Debug | Only runs the given scriptblock when the build target is Debug |
|
Release | Only runs the given scriptblock when the build target is Release. Also provides a -AndPrerelease switch to run for release AND prerelease targets |
|
Prerelease | Only runs the given scripblock when the build target is Prerelease |
|
SetPrereleaseTag | Sets the Prerelease property within a manifest file to mark the module as a prerelease within PSResourceGet or PowerShellGet |
|
UsingModule | Adds a using module command to the generated psm1 file |
|
Contributing
PSMake is open to community contributions! Please read the CONTRIBUTING.md file for details on how to contribute!