在 Azure devops 微软托管构建服务器上安装新版本的依赖项

Install new versions of dependencies on Azure devops microsoft hosted build server

我在 iOS 中的 Xamarin 移动应用程序的 azure 构建管道有问题。该问题要求单声道版本 6.10.0 在构建服务器上可用。目前,macOS 10.14 的预装映像仅包含 6.08 版以下的 Mono。 macOS 10.15 的图像确实包含正确版本的 Mono,但由于内部原因,我此时无法升级到 10.15。

有没有办法在构建之前更新管道以安装新版本的 Mono?或者我们是否完全受限于图像中包含的软件?我正在使用 Microsoft 托管服务器。

Azure Pipelines 托管代理是通用构建和部署代理。因此,Microsoft 不会添加某些人可能需要的任意旧版本软件。

但是,您确实可以访问自制软件和其他工具,这些工具可以让您在代理上安装所需的软件。您还可以访问设置环境变量。所以你可以只安装所有需要的软件。

至于继续使用 macOS 10.14 以及您需要的任何版本的单声道的要求。在某些时候,您必须意识到 Microsoft 提供的图像中的 none 将包含任何此软件。因此,如果您必须拥有此环境,请制作您自己的托管 macOS 代理并添加到您的池中以 运行 这样的东西。

Is there a way to update the pipeline to install the new version of Mono before building?

如您所说,Microsoft 托管代理中不存在 Mono 版本 6.10.0:Macos-10.14,但您可以 运行 脚本在安装目标 Mono 版本的 Xamarin 任务之前。

管道示例如下:

steps:
- bash: |
   #!/bin/bash
   set -ex
   
   
   MONO_MACOS_PKG_DOWNLOAD_URL='https://download.mono-project.com/archive/6.10.0/macos-10-universal/MonoFramework-MDK-6.10.0.49.macos10.xamarin.universal.pkg'
   
   
   mkdir -p /tmp/mono-install
   cd /tmp/mono-install
   
   # debug: mono version before the install
   mono --version
   
   # download mono mac installer (pkg)
   wget -q -O ./mono-installer.pkg "$MONO_MACOS_PKG_DOWNLOAD_URL"
   
   # install it
   sudo installer -pkg ./mono-installer.pkg -target /
   
   # debug: mono version after install, just to confirm it did overwrite the original version
   mono --version
   
   # just for fun print this symlink too, which should point to the version we just installed
   ls -alh /Library/Frameworks/Mono.framework/Versions/Current
  displayName: 'Bash Script'

- script: |
   mono -V
   
   cat `which mcs`
  displayName: 'Command Line Script'

这里是a Blog关于安装单声道的。

结果: