An MSBuild SDK and project template that enables PowerShell-driven builds for .NET solutions. Instead of compiling code, projects execute PowerShell scripts (build.ps1, clean.ps1, publish.ps1) with all MSBuild properties exposed as environment variables.
- Full MSBuild Integration - Works with
dotnet build,msbuild, Visual Studio, and CI/CD pipelines - PowerShell Scripts - Complete control over build, clean, and publish processes
- Environment Variables - All MSBuild properties exposed as
MBLD_*variables - Standard Output Paths - Follows .NET conventions (
bin/Debug/net8.0/) - Project Template - Quick start with
dotnet new psproj
dotnet new install DevPossible.PwshProject.Templatesdotnet new psproj -n MyProject
cd MyProjectdotnet build # Runs build.ps1
dotnet build -c Release
dotnet clean # Runs clean.ps1
dotnet publish # Runs publish.ps1MyProject/
├── MyProject.psproj # Project file (references the SDK)
├── build.ps1 # Build script - your build logic here
├── clean.ps1 # Clean script - cleanup logic
└── publish.ps1 # Publish script - deployment logic
- Your
.psprojfile referencesDevPossible.PwshProject.Sdk - When you run
dotnet build, the SDK intercepts the Build target - The SDK converts all MSBuild properties to
MBLD_*environment variables - Your
build.ps1script runs with full access to build context - Same pattern for Clean and Publish targets
Your scripts have access to all MSBuild properties via MBLD_* environment variables:
| Variable | Description | Example |
|---|---|---|
MBLD_PROJECT_DIR |
Project directory | C:\src\MyProject |
MBLD_PROJECT_NAME |
Project name | MyProject |
MBLD_CONFIGURATION |
Build configuration | Debug or Release |
MBLD_TARGET_FRAMEWORK |
Target framework | net8.0 |
MBLD_OUT_DIR |
Output directory | bin\Debug\net8.0\ |
MBLD_PUBLISH_DIR |
Publish directory | bin\publish\Release\ |
MBLD_VERSION |
Version number | 1.0.0 |
| ... | And 25+ more! |
#Requires -Version 7.0
$ErrorActionPreference = 'Stop'
Write-Host "Building $env:MBLD_PROJECT_NAME ($env:MBLD_CONFIGURATION)..."
# Ensure output directory exists
if (-not (Test-Path $env:MBLD_OUT_DIR)) {
New-Item -ItemType Directory -Path $env:MBLD_OUT_DIR -Force | Out-Null
}
# Your build logic here - examples:
# - Compile TypeScript: npx tsc --outDir $env:MBLD_OUT_DIR
# - Bundle JavaScript: npx webpack --mode production
# - Process templates: Copy-Item ./src/* $env:MBLD_OUT_DIR
# - Generate docs: docfx build
Write-Host "Build complete!"- TypeScript/JavaScript - Compile and bundle frontend code
- Static Sites - Generate Hugo, Jekyll, or custom static sites
- Asset Processing - Optimize images, compile SASS
- Multi-Step Pipelines - Complex build workflows
- Custom Deployments - Package and deploy applications
- Documentation - Generate and publish docs
Override SDK defaults in your project file:
<Project Sdk="DevPossible.PwshProject.Sdk/1.0.0">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<!-- Custom script names -->
<PwshBuildScript>my-build.ps1</PwshBuildScript>
<!-- Disable specific targets -->
<PwshCleanEnabled>false</PwshCleanEnabled>
<!-- Custom PowerShell executable -->
<PwshExecutable>pwsh.exe</PwshExecutable>
</PropertyGroup>
</Project>| Package | Description | NuGet |
|---|---|---|
DevPossible.PwshProject.Sdk |
MSBuild SDK | |
DevPossible.PwshProject.Templates |
Project template |
- .NET SDK 8.0 or later
- PowerShell 7.0 or later
# Clone the repository
git clone https://github.com/devpossible/devpossible-pwsh-projecttemplate.git
cd devpossible-pwsh-projecttemplate
# Run smoke tests
./test-smoke.ps1
# Build packages
./build.ps1 -Configuration Release
# Packages are created in .dist/- DevPossible.PwshBuildEvents - PowerShell pre/post build scripts for existing .NET projects
MIT