PSMake is an all-in-one project management and lifecycle toolset for PowerShell.
Please see the NOTICE regarding copyright and ownership information as it highly affects the LICENSE.
- 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
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.
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.
PS> PSMake template MyProjectName
PS> PSMake # Default parameters are 'build Release'
PS> PSMake build Release
PS> PSMake build Debug
PS> PSMake test
PS> PSMake test reports
PS> PSMake clean
PS> PSMake publish 'Your-NuGet-API-Key'
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.
Command | Description | Example |
AddType | Adds a C# file using Add-Type to the psm1 file |
AddType {
'classes/MyClass.cs'
} |
CodeSign | Code signs the returns files from the given scriptblock |
CodeSign {
'file1'
'file2'
} |
Collate | Brings multiple function ps1 files into a single psm1 file |
Collate {
'./functions/file1.ps1'
'./functions/file2.ps1'
} |
CopyDirectory | Copies directories into the distribution folder |
CopyDirectory {
'./functions'
} |
CopyFiles | Copies files into the distribution folder |
CopyFiles {
'manifest.psd1'
} |
CreateDirectory | Creates a directory in the distribution folder |
CreateDirectory {
'MyFolder'
} |
CustomCode | Adds codes to the generated psm1 file in the distribution folder |
CustomCode {
# Add custom code here
} |
Debug | Only runs the given scriptblock when the build target is Debug |
Debug {
CopyFiles {
'module.psm1'
}
} |
Release | Only runs the given scriptblock when the build target is Release. Also provides a -AndPrerelease switch to run for release AND prerelease targets |
Release {
Collate {
Get-ChildItem ./functions/*.ps1
}
} -AndPrerelease |
Prerelease | Only runs the given scripblock when the build target is Prerelease |
Prerelease {
SetPrereleaseTag {
'MyModuleManifest.psd1'
}
} |
SetPrereleaseTag | Sets the Prerelease property within a manifest file to mark the module as a prerelease within PSResourceGet or PowerShellGet |
SetPrereleaseTag {
'MyModuleManifest.psd1'
} |
UsingModule | Adds a using module command to the generated psm1 file |
UsingModule {
'MySpecialModule'
} |
PSMake is open to community contributions! Please read the CONTRIBUTING.md file for details on how to contribute!