2009-12-08 2 views
7

내가 원하는 것은 psake를 사용하여 필요한 빌드 프로세스를 실행할 수있는 하나의 파일입니다.배치 파일에서 psake를 사용하는 방법은 무엇입니까?

나는 psake와 PowerShell을 처음 사용하기 때문에 신중해야한다 :-).

파일 1 : Build.ps1

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

파일 3 : BuildTasks.ps1

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

파일이 경우 build.bat 내가 지금 무엇을 가지고

3 개 파일입니다

task default -depends Verify, Joe 

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

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

어쨌든 병합할까요? Build.ps1 및 BuildTasks.ps1을 하나의 파일로 만드시겠습니까?

답변

8

당신은 build.ps1 파일 없애는

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

이 작업을 수행 할 수 있어야합니다.

+0

요하네스 다음과 같습니다 것 같습니다. 고마워. 단 하나의 모든 수정. $ args 대신 % 1이 (가) 필요합니다. PowerShell -ExecutionPolicy 제한되지 않음 -Command "& {Import-Module. \ psake.psm1; Invoke-psake. \ BuildTasks.ps1 % 1" " –

+0

맞습니다. 죄송합니다. – Joey

1

Psake에는 전화를 감싸는 powershell 스크립트 "psake.ps1"이 함께 제공됩니다.

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

그래서 배치 스크립트가

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

당신이 언급 한 psake.ps1 파일은 invoke-psake 호출에 작업을 전달하는 데는 문제가 없지만 해시 테이블 (-parameters 및 -properties 인수)을 전달하려고 시도하면 실패합니다. 적어도 나는 그것을 작동시킬 수 없었다. – Jimit

관련 문제