You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在windows-latest虚拟机中为Xamarin安卓应用配置Github Actions

Windows-latest 虚拟机安装 Xamarin.Android 操作方案

核心操作逻辑

windows-latest 运行器默认预装 Visual Studio 2022,无需使用 macOS 环境下的 shell 安装脚本,直接通过 Visual Studio 安装器的命令行接口即可追加 Xamarin.Android 所需组件,全程无需手动交互。

具体工作流配置步骤

你可以直接在 GitHub Actions 的工作流文件中加入以下步骤:

  • 步骤1:安装 Xamarin.Android 相关工作负载
# 定位 Visual Studio 安装路径并执行组件安装
& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vs_installer.exe" modify `
  --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" `
  --add Microsoft.VisualStudio.Workload.XamarinBuildTools `
  --add Component.Xamarin.Android `
  --quiet --norestart --force

注:如果需要指定特定版本的 Xamarin.Android,可在组件 ID 后追加版本号,格式为Component.Xamarin.Android,version=xx.x.xxx

  • 步骤2:验证安装生效
    安装完成后可通过以下命令确认 Xamarin.Android 正常识别:
msbuild /version
# 或直接执行Android项目构建命令验证
msbuild YourApp.Android.csproj /t:Build /p:Configuration=Release

注意事项

  • 该方案仅支持构建 Xamarin.Android 应用,Xamarin.iOS 应用仍需在 macOS 系列运行器上完成编译,和你已知的限制一致
  • 组件安装过程通常耗时2-5分钟,可根据需求将配置好的环境打包为自定义运行器镜像缩短执行时间

内容的提问来源于stack exchange,提问作者Dominique

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 23:15:07