Dinomite-Studios / unity-azure-pipelines-tasks

Azure DevOps extension adding tools to build and deploy Unity 3D projects using Azure Pipelines
https://unitydevops.com/
MIT License
121 stars 49 forks source link

Activate license without opening a Unity project #215

Closed oakie closed 1 year ago

oakie commented 1 year ago

I have a pipeline setup in which I try to activate the license in the first step, and build the project to a number of target platforms in subsequent steps. My issue is that the activation takes over 5 minutes to complete, and upon inspection of the logs, it seems that most of that time was spent importing assets to the library. The problem is made worse by the fact that the license activation task does not allow me to specify a build target, so the library will have to be rebuilt during the build step towards the correct build target.

Is it possible to somehow skip opening the unity project during the license activation?

krisrok commented 1 year ago

If you got a dedicated build machine you can do it like this:

  1. Put a barebones unity project somewhere on your machine. I cobbled together this one: https://file.io/kBM7qBcEcSmX (27kB)
  2. Locate and modify your unity-activate-license.js (.js not .ts), and add the commandline args:
    const unityCmd = tl.tool(unityExecutablePath)
        .arg('-batchmode')
        .arg('-quit')
        .arg('-nographics')
        .arg('-username').arg(username)
        .arg('-password').arg(password)
        .arg('-serial ').arg(serial)
        .arg('-logfile').arg(logFilePath)
        .arg('-ignorecompilererrors')
        .arg('-projectpath').arg('<path_to_the_barebones_project>');

This then only takes about ~5s on our build machine for license activation. First run was 8s because Library had to be built :)

This change gets overwritten if the .ts gets retranspiled though so it's only a POC/workaround type of thing.

FejZa commented 1 year ago

This has been addressed in v2.7.1 some time ago. The activate license task does not specify a project path anymore and instead activates using a default empty project.