开发者

How to use psake from a batch file?

开发者 https://www.devze.com 2022-12-13 16:43 出处:网络
What I want is a one file I can double-click that will run the required build process using psake. I\'m new to psake and PowerShell so be gentle :-).

What I want is a one file I can double-click that will run the required build process using psake.

I'm new to psake and PowerShell so be gentle :-).

What I have now are 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 th开发者_如何学Cere anyway to merge Build.ps1 and BuildTasks.ps1 into one file?


You should be able to do this with

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

which gets rid of the build.ps1 file.


Psake comes with a powershell script "psake.ps1" which wraps the call for you. It looks like:

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

So your batch script looks like

powershell {path-to-module}\psake.ps1 .\buildTasks.ps1
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号