diff --git a/pipelines/templates/common.yml b/pipelines/templates/common.yml index 4fb5f67cd6b..d97c514ad32 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 + # Module management requires TLS 1.2. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - Install-Module -Name UnitySetup -Scope CurrentUser -Force + if (-not (Get-InstalledModule -Name UnitySetup)) { + 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..2ed51ae09f7 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 + # Module management requires TLS 1.2. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - Install-Module -Name UnitySetup -Scope CurrentUser -Force + if (-not (Get-InstalledModule -Name UnitySetup)) { + 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..da26b7e08a7 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,14 @@ parameters: default: '' steps: -- powershell: | +- pwsh: | + # Module management requires TLS 1.2. + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + # UnitySetup 5.5.146-develop specifically added support for Unity 2021. + if (-not (Get-InstalledModule -Name UnitySetup -MinimumVersion "5.5.146-develop" -AllowPrerelease)) { + 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..2f23842950f 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 + # Module management requires TLS 1.2. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - Install-Module -Name UnitySetup -Scope CurrentUser -Force + if (-not (Get-InstalledModule -Name UnitySetup)) { + Install-Module -Name UnitySetup -Scope CurrentUser -Force + } displayName: Install unitysetup.powershell - powershell: |