2017-11-27 1 views
1

Psake 빌드 도구에서 Cake (https://cakebuild.net/)로 전환합니다. 저는 (현재) 9 가지의 다른 배포판을 가진 매우 큰 솔루션 (30 개 이상의 프로젝트)을위한 스크립트를 만들고 있습니다. Psake에서는 전체 스크립트가 powershell에서 실행 중이므로 PowerShell 명령을 호출하는 것은 간단합니다.Cake 작업 내에서 powershell 명령을 호출 할 수 있습니까?

하지만 지금 문제가 있습니다. PS에서 실행중인 일부 명령을 호출해야하지만이를 실행할 수있는 방법을 찾을 수 없습니다.

몇 가지 예 : 나는 StartAndReturnProcess으로 시도했습니다

taskkill /IM iisexpress.exe 
Invoke-Command -ComputerName <testing server> -ScriptBlock {import-module WebAdministration; Stop-Website <'name of website'>} 
Invoke-Command -ComputerName <testing server> -ScriptBlock {import-module WebAdministration; Start-Website <'name of website'>} 

(예 : StartAndReturnProcess ("에서 taskkill/IM iisexpress.exe");), 그러나 성공하지. 또한 Cake.IIS 플러그인을 발견했는데 IIS 시작 및 중지에 대한 내 문제를 해결할 수있을 것입니다. 그러나 smoe 다른 PS 명령도 호출하고 싶습니다.

Task에서 PowerShell 명령을 간단하게 호출 할 수 있습니까? 이 같은 뭔가 : 어떤 대답과 안부를위한

Task("DoSomeMagic") 
    .Does(() => 
{ 

    ExecutePowerShellCommad("taskkill /IM iisexpress.exe"); 
    ExecutePowerShellCommad("Invoke-Command -ComputerName <testing server> -ScriptBlock {import-module WebAdministration; Stop-Website <'name of website'>}"); 

    //ToDo: other magic 
}); 

고맙습니다,

답변

2

마틴 당신은 Cake.PowerShell 추가 기능을 본 적이 있습니까?

사용 예제는 here을 발견 할 수 있지만 (추가 정보에서 가져온) 예를 제공하기 위해 :

#addin "Cake.Powershell" 

Task("Powershell-Script") 
    .Description("Run an example powershell command with parameters") 
    .Does(() => 
{ 
    StartPowershellScript("Write-Host", args => 
     { 
      args.AppendQuoted("Testing..."); 
     }); 
}); 

정확히 당신이 달성하려고하는 내용에 따라 추가 정보에서 더 복잡한 예제가 있습니다.

+0

아니요, 아닙니다. Tjhank, 너 지금 당장 시험해 보자. :) –

+1

너보다 훨씬 귀엽고, 매력처럼 작동한다. –

+0

Woot! 그것을 듣기 좋게 :-) –

관련 문제