简体   繁体   中英

VSTS Run Powershell Script on Mac with Parameters

I have a Xamarin.Forms project wherein the Android project is built in VSTS using a hosted build agent which runs a powershell script at run-time.

I need to run the same powershell script against the Xamarin.iOS which uses an On Premise Mac Build Agent. But how?

I found this answer and a comment under the answer also had the same question regarding parameters, so I am posting the solution here since the issue is slightly different and that question has an accepted answer.

First off, I installed powershell on the mac using these instructions and I modified the shell script task to include the Visual Studio Team Services (VSTS) environmental variables that I wanted to pass to the powershell script.

在此处输入图片说明

Next, I pass the arguments through to the called powershell script by slightly modifying the shell script mentioned by the referenced answer .

#!/bin/bash
powershell ./Version.ps1 $1 $2

Finally, in the powershell script, I catch the arguments that have been passed through using using param like this:

param([string]$version, [string]$path)

Wherein I can now use the variables $version and $path which contain the original arguments entered in VSTS to the needs of my powershell script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM