繁体   English   中英

如何在 azure devOps 中设置用于构建统一项目的管道

[英]How to set pipeline for building unity project in azure devOps

我是创建管道的新手,我需要创建一个来构建我的统一项目和 C# 脚本。 我试试这个:

https://dinomite-studios.github.io/unity-azure-pipelines-tasks/hosted-agent.html (在这次尝试中我没有 Unity Active License 序列号,因此我删除了这个任务,但我的第二个 PowerShell脚本没有通过)为此我收到此错误:

Starting: PowerShell Script
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.170.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\2178f08e-dbac-43f8-a053-1a2420d6c47c.ps1'"
Find-UnitySetupInstaller : The term 'Find-UnitySetupInstaller' is not recognized as the name of a cmdlet, function, 
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is 
correct and try again.
At D:\a\_temp\2178f08e-dbac-43f8-a053-1a2420d6c47c.ps1:3 char:41
+ ... tall-UnitySetupInstance -Installers (Find-UnitySetupInstaller -Versio ...
+                                          ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Find-UnitySetupInstaller:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : CommandNotFoundException
 
##[error]PowerShell exited with code '1'.
Finishing: PowerShell Script

和这个:

https://medium.com/medialesson/continuous-integration-for-unity-3d-projects-using-azure-pipelines-e61ddf64ad79为此我收到此错误:

Starting: Unity Build Android
==============================================================================
Task         : Unity Build
Description  : Build a Unity project and get the exported output files.
Version      : 3.1.1
Author       : Dinomite Studios
Help         : Builds a Unity project to supported build target platforms. [More Information](https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks)
==============================================================================
Determining Unity editor version for project at D:\a\1\s\virtualterminal-realwear\VirtualTerminal
Success, Unity editor version found 2019.3.9f1, alpha=false, beta=false
Unable to locate executable file: 'C:\Program Files\Unity\Hub\Editor\2019.3.9f1\Editor\Unity.exe'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
##[error]Unable to locate executable file: 'C:\Program Files\Unity\Hub\Editor\2019.3.9f1\Editor\Unity.exe'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
Finishing: Unity Build Android

我只尝试使用“VisualStudioBuild”任务,但没有任何效果。

有人能告诉我该怎么做吗?

Find-UnitySetupInstaller :术语“Find-UnitySetupInstaller”不被识别为 cmdlet、函数、脚本文件或可运行程序的名称。

对于您遇到的第一个错误,如果您查看第一个 Powershell 任务的日志,您会发现一条警告消息: WARNING: User declined to install module (UnitySetup) 换句话说,即使任务以绿色通过,模块UnitySetup也没有安装成功。 我们的 Azure DevOps 系统拒绝安装此模块。

这就是为什么您遇到the cmdlet xxx is not recognized错误的原因。 那是因为父模块UnitySetup还没有安装成功。

要解决此问题,需要在第一个 Powershell 任务中的Install-module命令后附加-Force 参数

Install-Module UnitySetup -AllowPrerelease -Scope CurrentUser -Force 

##[错误]无法找到可执行文件:'C:\\Program Files\\Unity\\Hub\\Editor\\2019.3.9f1\\Editor\\Unity.exe'。

根据您分享的第二个日志,您正在使用Hosted agent ,对吗? 并且似乎您没有添加Unity Get Project Version taskPowershell tasks来将Unity工具安装到环境中,因为您正在关注此博客的管道定义示例。

如果仔细查看该博客,您会发现博客作者在 Azure DevOps 中配置管道之前,已在本地计算机上手动预安装了自代理,并在代理上安装了 Unity Hub。

在此处输入图片说明

总之, Unity.exe已经存在于作者的构建环境中,所以这里省略了使用Powershell脚本安装Unity步骤。 但是我们的Hosted agent并没有在我们的机器上安装这个可执行文件,这意味着您在使用Hosted agent时必须自己安装它。


根据我的观点,我强烈建议您按照您提到的第二篇博客来配置您的管道,这可以节省您的构建执行时间:

1) 先安装自代理。

2)安装 Unity.exe 和需要的统一版本。

3)配置管道。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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