0

I am new to cake build. I want to run Microsoft appcenter command from Cake script. I tried using cake.powershell for it https://cakebuild.net/addins/powershell/

 StartPowershellFile("./appcenter.ps1"); 

// appcenter.ps1 had just CLI command for Appcenter "appcenter test run uitest --app \"5678999\" --devices \"7738\" --app-path ./iPhone.ipa --test-series \"master\" --locale \"en_US\" --build-dir /iPhone/bin/Debug"

This did not work.

I also tried

StartProcess("./appcenter.ps1");

from https://cakebuild.net/dsl/process/

Can anyone suggest or provide sample code how can I run CLI commands from cake script? I need to run CLI for Microsoft Appcenter tool.

TheDeveloper
  • 901
  • 14
  • 45

2 Answers2

2

Here you have a few options.

If you want to continue to use the StartProcess alias, you will need to give it the application that you want to execute, in your case, PowerShell. The file that you want to run would likely then become the argument that you pass in. So, you would need to do something similar to:

StartProcess("powershell", new ProcessSettings{ Arguments = "./appcenter.ps1" });

NOTE: This is untested, and may need to be altered in order for it to function.

More information about the overload used for StartProcess can be found here:

https://cakebuild.net/api/Cake.Common/ProcessAliases/81E648CC

The second, probably preferred option, would be to use the Cake.PowerShell addin:

https://github.com/SharpeRAD/Cake.Powershell

This would allow you to do:

StartPowershellFile("./appcenter.ps1");

Finally, I "think" you are trying to utilise the same endpoint that is being used within this Addin:

https://github.com/cake-contrib/Cake.WindowsAppStore

Perhaps you could collaborate with the original author of that addin to extend it to include the required functionality that you are trying to use.

Gary Ewan Park
  • 13,805
  • 4
  • 29
  • 53
1

After going through Gary's suggestions, I ended up using StartProcess:

StartProcess("appcenter", new ProcessSettings{
                    Arguments = "test run uitest 
                     --app \"MyApp\" 
                     --devices \"45678\" 
                     --app-path /TheApp.ipa  
                     --test-series \"master\" 
                     --locale \"en_US\" 
                     --build-dir /UITest/bin/Debug"
                });
TheDeveloper
  • 901
  • 14
  • 45