带有参数的VSTS在Mac上运行Powershell脚本

时间:2017-08-22 20:21:38

标签: powershell xamarin.ios azure-devops visual-studio-mac

我有一个Xamarin.Forms项目,其中Android项目是使用托管构建代理在VSTS中构建的,该代理在运行时运行PowerShell脚本。

我需要针对使用On Premise Mac Build Agent的Xamarin.iOS运行相同的powershell脚本。但是如何?

1 个答案:

答案 0 :(得分:0)

我发现这个answer并且答案下的评论也有关于参数的相同问题,所以我在这里发布解决方案,因为问题略有不同,而且该问题已经接受了答案。

首先,我使用these instructions在mac上安装了powershell,我修改了shell脚本任务,以包含我想传递给powershell脚本的Visual Studio Team Services(VSTS)环境变量。

enter image description here

接下来,我通过稍微修改referenced answer提到的shell脚本,将参数传递给被调用的powershell脚本。

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

最后,在powershell脚本中,我使用这样的param来捕获已经传递的参数:

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

其中我现在可以使用包含在VSTS中输入的原始参数的变量$ version和$ path来满足我的powershell脚本的需要。

相关问题