Skip to main content
psake logo

psake

A build automation tool written in PowerShell

...Stars
PowerShell GalleryLicense
psakeFile.ps1
# psakeFile.ps1
Task Default -Depends Test, Build

Task Build -Depends Clean {
Write-Host "Building project..." -ForegroundColor Green
dotnet build -c Release
}

Task Test {
Write-Host "Running tests..." -ForegroundColor Cyan
dotnet test --no-build
}

Task Clean {
Write-Host "Cleaning output..." -ForegroundColor Yellow
Remove-Item ./bin -Recurse -Force -ErrorAction Ignore
}

Task Deploy -Depends Build {
Write-Host "Deploying to production..." -ForegroundColor Magenta
# Your deployment logic here
}

Why Choose psake?

Powerful features designed for modern build automation

🔗

Task Dependencies

Define clear dependencies between tasks for organized, predictable builds

Task Deploy -Depends Build, Test {
# Deploy only after build and test succeed
}
🌍

Cross-Platform

Runs on Windows, macOS, and Linux with PowerShell 7+

# Works everywhere PowerShell runs
Task Build {
dotnet build -c Release
}

Simple Syntax

Clean, readable task definitions that are easy to understand and maintain

Task Clean {
Remove-Item ./bin -Recurse -Force
}
🔍

Built-in Assertions

Validate conditions and fail fast with helpful error messages

Task Deploy {
Assert (Test-Path ./build) "Build folder required"
}
🚀

CI/CD Ready

Integrates seamlessly with GitHub Actions, Azure DevOps, and Jenkins

# GitHub Actions
- run: Invoke-psake -taskList CI
shell: pwsh
📦

Flexible Properties

Configure builds with properties and override them at runtime

Properties {
$Configuration = "Release"
}
# Override: Invoke-psake -properties @{Configuration="Debug"}
🎯

Preconditions

Skip tasks conditionally based on your build environment

Task Deploy -Precondition { $Env -eq "Prod" } {
# Only runs in production
}
🛠️

PowerShell Ecosystem

Use any PowerShell module or script in your build tasks

Task Test {
Invoke-Pester -Path ./tests
# Use Pester, PSScriptAnalyzer, etc.
}

See psake in Action

Real-world examples showing how psake simplifies build automation

A basic build workflow with dependencies

psakeFile.ps1
# Simple psakeFile.ps1
Task Default -Depends Build

Task Build -Depends Clean, Compile {
Write-Host "Build completed!" -ForegroundColor Green
}

Task Clean {
Remove-Item ./bin -Recurse -Force -ErrorAction Ignore
}

Task Compile {
dotnet build -c Release
}
Terminal Output
psake version 4.9.0
Copyright (c) 2010-2024 James Kovacs & Contributors

Executing Clean
Executing Compile
Executing Build
Build completed!

Build Succeeded!

Get Started in 3 Steps

Start automating your builds in minutes

1

Install psake

Install psake from the PowerShell Gallery

Install-Module -Name psake -Scope CurrentUser
2

Create psakeFile.ps1

Define your build tasks in a psakeFile.ps1

Task Default -Depends Build

Task Build {
Write-Host "Building project..." -ForegroundColor Green
# Your build logic here
}
3

Run Your Build

Execute psake to run your tasks

Invoke-psake