如何在 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\_temp78f08e-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\_temp78f08e-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
还有这个:
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\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\Editor19.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\Editor19.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 : The term 'Find-UnitySetupInstaller' is not
recognized as the name of a cmdlet, function, script file, or operable
program.
对于您遇到的第一个错误,如果您查看 第一个 Powershell 任务 的日志,您会发现一条警告消息:WARNING: User declined to install module (UnitySetup)
。换句话说,即使任务以绿色通过,模块 UnitySetup
也没有安装成功。我们的 Azure devops 系统拒绝安装此模块。
这就是您遇到 the cmdlet xxx is not recognized
错误的原因。那是因为父模块UnitySetup
还没有安装成功
要解决此问题,需要在第一个 Powershell 任务中的 Install-module
命令后附加 -Force
parameter:
Install-Module UnitySetup -AllowPrerelease -Scope CurrentUser -Force
##[error]Unable to locate executable file: 'C:\Program Files\Unity\Hub\Editor19.3.9f1\Editor\Unity.exe'.
根据您分享的第二个日志,您正在使用 Hosted agent,对吗?而且您似乎还没有添加 Unity Get Project Version task
和 Powershell tasks
来将 Unity 工具安装到环境中,因为您遵循的是此 blog 的管道定义示例.
如果仔细查看该博客,您会发现博客作者在 Azure devops 中配置管道之前,在本地计算机上手动设置了 pre-installed 自我代理,以及安装在代理上的 Unity Hub。
总之作者的搭建环境中已经存在Unity.exe
,所以这里省略了使用Powershell脚本安装Unity
的步骤。但是我们的Hosted agent并没有在我们的机器上安装这个可执行文件,这意味着您在使用Hosted agent时必须自己安装它。
根据我的意见,我强烈建议您按照您提到的第二篇博客来配置您的管道,这可以节省您的构建执行时间:
1)先安装自代理。
2) 安装 Unity.exe 和需要的统一版本。
3) 配置管道。
我是创建管道的新手,我需要创建一个管道来构建我的统一项目和 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\_temp78f08e-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\_temp78f08e-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
还有这个:
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\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\Editor19.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\Editor19.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 : The term 'Find-UnitySetupInstaller' is not recognized as the name of a cmdlet, function, script file, or operable program.
对于您遇到的第一个错误,如果您查看 第一个 Powershell 任务 的日志,您会发现一条警告消息:WARNING: User declined to install module (UnitySetup)
。换句话说,即使任务以绿色通过,模块 UnitySetup
也没有安装成功。我们的 Azure devops 系统拒绝安装此模块。
这就是您遇到 the cmdlet xxx is not recognized
错误的原因。那是因为父模块UnitySetup
还没有安装成功
要解决此问题,需要在第一个 Powershell 任务中的 Install-module
命令后附加 -Force
parameter:
Install-Module UnitySetup -AllowPrerelease -Scope CurrentUser -Force
##[error]Unable to locate executable file: 'C:\Program Files\Unity\Hub\Editor19.3.9f1\Editor\Unity.exe'.
根据您分享的第二个日志,您正在使用 Hosted agent,对吗?而且您似乎还没有添加 Unity Get Project Version task
和 Powershell tasks
来将 Unity 工具安装到环境中,因为您遵循的是此 blog 的管道定义示例.
如果仔细查看该博客,您会发现博客作者在 Azure devops 中配置管道之前,在本地计算机上手动设置了 pre-installed 自我代理,以及安装在代理上的 Unity Hub。
总之作者的搭建环境中已经存在Unity.exe
,所以这里省略了使用Powershell脚本安装Unity
的步骤。但是我们的Hosted agent并没有在我们的机器上安装这个可执行文件,这意味着您在使用Hosted agent时必须自己安装它。
根据我的意见,我强烈建议您按照您提到的第二篇博客来配置您的管道,这可以节省您的构建执行时间:
1)先安装自代理。
2) 安装 Unity.exe 和需要的统一版本。
3) 配置管道。