diff --git a/pipelines/templates/common.yml b/pipelines/templates/common.yml index 4fb5f67cd6b..38aba7bdd1f 100644 --- a/pipelines/templates/common.yml +++ b/pipelines/templates/common.yml @@ -10,9 +10,11 @@ parameters: steps: - powershell: | - # Some machines require that the protocol be explicitly set to Tls12 - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - Install-Module -Name UnitySetup -Scope CurrentUser -Force + if (-not (Get-InstalledModule -Name UnitySetup)) { + # Some machines require that the protocol be explicitly set to Tls12 + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + Install-Module -Name UnitySetup -Scope CurrentUser -Force + } displayName: Install unitysetup.powershell # Build Standalone x64. diff --git a/pipelines/templates/tasks/assetretargeting.yml b/pipelines/templates/tasks/assetretargeting.yml index 4a4f840390e..a24b8c3a9db 100644 --- a/pipelines/templates/tasks/assetretargeting.yml +++ b/pipelines/templates/tasks/assetretargeting.yml @@ -5,9 +5,11 @@ parameters: steps: - powershell: | - # Some machines require that the protocol be explicitly set to Tls12 - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - Install-Module -Name UnitySetup -Scope CurrentUser -Force + if (-not (Get-InstalledModule -Name UnitySetup)) { + # Some machines require that the protocol be explicitly set to Tls12 + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + Install-Module -Name UnitySetup -Scope CurrentUser -Force + } displayName: Install unitysetup.powershell - powershell: | diff --git a/pipelines/templates/tasks/build-appx.yaml b/pipelines/templates/tasks/build-appx.yaml index e78a2428ec6..60ecad83704 100644 --- a/pipelines/templates/tasks/build-appx.yaml +++ b/pipelines/templates/tasks/build-appx.yaml @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + # [Template] Build appx from a Unity-built sln. parameters: diff --git a/pipelines/templates/tasks/build-unity.yaml b/pipelines/templates/tasks/build-unity.yaml index 08c3918534d..30602910ff9 100644 --- a/pipelines/templates/tasks/build-unity.yaml +++ b/pipelines/templates/tasks/build-unity.yaml @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + # [Template] Build project inside Unity. parameters: @@ -25,7 +28,13 @@ parameters: default: '' steps: -- powershell: | +- pwsh: | + # UnitySetup 5.5.146-develop specifically added support for Unity 2021. + if (-not (Get-InstalledModule -Name UnitySetup -MinimumVersion "5.5.146-develop" -AllowPrerelease)) { + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + Install-Module UnitySetup -Scope CurrentUser -Force -AllowPrerelease + } + $logFile = Join-Path $(Agent.TempDirectory) "build_${{ parameters.BuildTarget }}.log" $proc = Start-UnityEditor -Project ${{ parameters.PathToProject }} -Version ${{ parameters.UnityVersion }} -ExecuteMethod ${{ parameters.CommandLineBuildMethod }} -BatchMode -Quit -PassThru -LogFile $logFile -BuildTarget ${{ parameters.BuildTarget }} -OutputPath ${{ parameters.OutputPath }} -AdditionalArguments "-CacheServerIPAddress ${Env:COG-UnityCache-WUS2-01} ${{ parameters.AdditionalArguments }}" $ljob = Start-Job -ScriptBlock { param($log) Get-Content "$log" -Wait } -ArgumentList $logFile diff --git a/pipelines/templates/tasks/generate-projects.yml b/pipelines/templates/tasks/generate-projects.yml index 7a9c83e426c..16801d52cd8 100644 --- a/pipelines/templates/tasks/generate-projects.yml +++ b/pipelines/templates/tasks/generate-projects.yml @@ -5,9 +5,11 @@ parameters: steps: - powershell: | - # Some machines require that the protocol be explicitly set to Tls12 - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - Install-Module -Name UnitySetup -Scope CurrentUser -Force + if (-not (Get-InstalledModule -Name UnitySetup)) { + # Some machines require that the protocol be explicitly set to Tls12 + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + Install-Module -Name UnitySetup -Scope CurrentUser -Force + } displayName: Install unitysetup.powershell - powershell: |