How to use psake from a batch file?

What I want is a single file that I can double-click, which will complete the required build process with psake.

I am new to psake and PowerShell, so be careful :-).

Now I have 3 files:

File 1: Build.bat

PowerShell -ExecutionPolicy Unrestricted -File .\Build.ps1 %1 

File 2: Build.ps1

 Import-Module .\psake.psm1 Invoke-psake .\BuildTasks.ps1 $args 

File 3: BuildTasks.ps1

 task default -depends Verify, Joe task Verify { write-host "hello from Verify!" } task Joe { write-host "hello from Joe" } 

Is it possible to combine Build.ps1 and BuildTasks.ps1 into one file?

+7
build batch-file psake
source share
2 answers

You can do it with

 powershell -Command "& {Import-Module .\psake.psm1; Invoke-psake .\BuildTasks.ps1 %*}" 

which gets rid of the build.ps1 file.

+8
source share

Psake comes with a powershell script "psake.ps1" that completes the call for you. It looks like this:

 import-module .\psake.psm1 invoke-psake @args remove-module psake 

So your batch script looks like

 powershell {path-to-module}\psake.ps1 .\buildTasks.ps1 
+1
source share

All Articles