7

我想要的是一个我可以双击的文件,它将使用 psake 运行所需的构建过程。

我是 psake 和 PowerShell 的新手,所以要温柔:-)。

我现在有3个文件:

文件 1:Build.bat

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

文件 2:构建.ps1

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

文件 3:BuildTasks.ps1

task default -depends Verify, Joe

task Verify {
    write-host "hello from Verify!"
}

task Joe {
    write-host "hello from Joe"
}

无论如何将 Build.ps1 和 BuildTasks.ps1 合并到一个文件中?

4

2 回答 2

8

你应该能够做到这一点

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

它摆脱了build.ps1文件。

于 2009-12-08T08:35:16.630 回答
1

Psake 带有一个 powershell 脚本“psake.ps1”,它为您包装了调用。看起来像:

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

所以你的批处理脚本看起来像

powershell {path-to-module}\psake.ps1 .\buildTasks.ps1
于 2010-08-31T13:07:19.060 回答