简体   繁体   中英

How to set pipeline for building unity project in azure devOps

I am new in creating pipelines and I need to create one to build my unity project and C# scripts. I try this:

https://dinomite-studios.github.io/unity-azure-pipelines-tasks/hosted-agent.html (in this try I have not Unity Active License serial key and because of that I remove this task, but my second PowerShell script doesn't pass) for this I get this error:

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

and this:

https://medium.com/medialesson/continuous-integration-for-unity-3d-projects-using-azure-pipelines-e61ddf64ad79 for this I get this error:

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

and I try with only "VisualStudioBuild" Task, but nothing doesn't work.

Can someone tell me how to do it right?

Find-UnitySetupInstaller : The term 'Find-UnitySetupInstaller' is not recognized as the name of a cmdlet, function, script file, or operable program.

For the first error your encountered, if you check the log of first Powershell task , you will find one warning message: WARNING: User declined to install module (UnitySetup) . In another word, the module UnitySetup is not installed successfully even the task is pass with green. Our Azure devops system refuse to install this module.

That's why you encountered the cmdlet xxx is not recognized error. That's because the parent module UnitySetup has not installed successfully yet.

To resolve this issue, Need to append -Force parameter after the Install-module command in first Powershell task:

Install-Module UnitySetup -AllowPrerelease -Scope CurrentUser -Force 

##[error]Unable to locate executable file: 'C:\\Program Files\\Unity\\Hub\\Editor\\2019.3.9f1\\Editor\\Unity.exe'.

According to the second log you shared, you are using Hosted agent , right? And seems also you didn't add Unity Get Project Version task and Powershell tasks to install Unity tool into environment since you were following the pipeline definition sample of this blog .

If you review that blog carefully, you will find that the blog author has pre-installed the self agent on local machine manually before he configured the pipeline in Azure devops, along with Unity Hub installed on the agent.

在此处输入图片说明

In short, the Unity.exe has been exists in author's building environment, so the installing Unity steps with Powershell scripts omitted here. BUT our Hosted agent has not installed this executable file in our machine, which means you must install it by yourself when you are using Hosted agent.


Per my opinion, I strongly suggest you to follow the second blog you mentioned to configure your pipeline which can save your build execution time:

1) Install self agent first.

2) Install Unity.exe and needed unity version.

3) Configure pipeline.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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