From ae9364b2444140f22341c91bfeb9d6760ccfe6d9 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 14 Dec 2021 16:10:20 -0800 Subject: [PATCH 01/14] Initial work --- pipelines/templates/tasks/build-appx.yml | 59 ++++++++++++++++++ pipelines/templates/tasks/build-unity.yml | 73 +++++++++++++++++++++++ pipelines/templates/tasks/unitybuild.yml | 46 ++------------ scripts/packaging/createupmpackages.ps1 | 31 +++++----- 4 files changed, 151 insertions(+), 58 deletions(-) create mode 100644 pipelines/templates/tasks/build-appx.yml create mode 100644 pipelines/templates/tasks/build-unity.yml diff --git a/pipelines/templates/tasks/build-appx.yml b/pipelines/templates/tasks/build-appx.yml new file mode 100644 index 00000000000..e4fa2d601dc --- /dev/null +++ b/pipelines/templates/tasks/build-appx.yml @@ -0,0 +1,59 @@ +# [Template] Build appx from a Unity-built sln. + +parameters: +- name: PathToSolution + type: string + default: $(Build.SourcesDirectory)/TestProjects/Main +- name: Arch + type: string + values: + - x86 + - x64 + - arm + - arm64 + +steps: +- task: MSBuild@1 + displayName: Build UWP ${{ parameters.Arch }} AppX + inputs: + solution: ${{ parameters.PathToSolution }} + platform: ${{ parameters.Arch }} + configuration: Master + + +- powershell: | + $nugetRestoreLogFileName = "$logDirectory\nugetRestore.log" + if (Test-Path $nugetRestoreLogFileName) + { + Write-Output '=====================================================' + Write-Output ' Begin NuGet Restore Log ' + Write-Output '=====================================================' + + Get-Content $nugetRestoreLogFileName + + Write-Output '=====================================================' + Write-Output ' End NuGet Restore Log ' + Write-Output '=====================================================' + } + else + { + Write-Output "NuGet Restore Log Missing $nugetRestoreLogFileName!" + } + + $appxBuildLogFileName = "$logDirectory\buildAppx.log" + if (Test-Path $appxBuildLogFileName) + { + Write-Output '=====================================================' + Write-Output ' Begin AppX Build Log ' + Write-Output '=====================================================' + + Get-Content $appxBuildLogFileName + + Write-Output '=====================================================' + Write-Output ' End AppX Build Log ' + Write-Output '=====================================================' + } + else + { + Write-Output "AppX Build Log Missing $appxBuildLogFileName!" + } \ No newline at end of file diff --git a/pipelines/templates/tasks/build-unity.yml b/pipelines/templates/tasks/build-unity.yml new file mode 100644 index 00000000000..79ca05a3bc6 --- /dev/null +++ b/pipelines/templates/tasks/build-unity.yml @@ -0,0 +1,73 @@ +# [Template] Compile MRTK inside Unity. + +parameters: +- name: Architectures + type: object + default: + - x86 + - ARM +- name: Platform + type: string + values: + - UWP + - Standalone +- name: PublishArtifacts + type: boolean + default: false +- name: UnityVersion + type: string + +steps: +- powershell: Install-Module UnitySetup -Scope CurrentUser -Force + displayName: Install unitysetup.powershell + +- ${{ if eq(parameters.Platform, 'UWP') }}: + - powershell: | + $logFile = "build_uwp.log" + Start-UnityEditor -Project ${{ parameters.PathToProject }} -Version ${{ parameters.UnityVersion }} -ExecuteMethod Microsoft.MixedReality.Toolkit.Build.Editor.UnityPlayerBuildTools.StartCommandLineBuild -BatchMode -Quit -Wait -LogFile $logFile -BuildTarget WSAPlayer -OutputPath build/uwp -AdditionalArguments "-CacheServerIPAddress ${Env:COG-UnityCache-WUS2-01}" + if (Test-Path $logFile) + { + Get-Content $logFile + } + displayName: Build UWP + + - task: PowerShell@2 + displayName: Validate build logs + inputs: + targetType: filePath + filePath: ./scripts/ci/validatebuildlog.ps1 + arguments: > + -LogFile: '$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}\build\build.log' + + - ${{ each arch in parameters.Architectures }}: + - task: MSBuild@1 + displayName: Build UWP ${{ arch }} AppX + inputs: + solution: ${{ parameters.PathToProject }}/build/uwp/${{ parameters.ProjectName }}.sln + platform: ${{ arch }} + configuration: Master + + - task: CopyFiles@2 + displayName: Copy UWP ${{ arch }} AppX to artifacts staging directory + inputs: + sourceFolder: ${{ parameters.PathToProject }}/build/uwp/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_$(buildNumber).0_${{ arch }}_Master_Test + targetFolder: $(Build.ArtifactStagingDirectory)/Apps/uwp-${{ arch }} + +- ${{ if eq(parameters.Platform, 'Standalone') }}: + - ${{ each arch in parameters.Architectures }}: + - powershell: | + $logFile = "build_standalone_${{ arch }}.log" + Start-UnityEditor -Project ${{ parameters.PathToProject }} -Version ${{ parameters.UnityVersion }} -ExecuteMethod ${{ parameters.CommandLineBuildMethod }} -BatchMode -Quit -Wait -LogFile $logFile -BuildTarget StandaloneWindows64 -OutputPath build/standalone_${{ arch }}/${{ parameters.ProjectName }}.exe -AdditionalArguments "-CacheServerIPAddress ${Env:COG-UnityCache-WUS2-01}" + if (Test-Path $logFile) + { + Get-Content $logFile + } + displayName: Build StandaloneWindows64 + + - task: PowerShell@2 + displayName: Validate build logs + inputs: + targetType: filePath + filePath: ./scripts/ci/validatebuildlog.ps1 + arguments: > + -LogFile: '$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}\build\build.log' diff --git a/pipelines/templates/tasks/unitybuild.yml b/pipelines/templates/tasks/unitybuild.yml index 827e7d6cc54..1bb92b26cc3 100644 --- a/pipelines/templates/tasks/unitybuild.yml +++ b/pipelines/templates/tasks/unitybuild.yml @@ -48,7 +48,7 @@ steps: $extraArgs = "" if ("${{ parameters.Platform }}" -eq "UWP") { - $extraArgs += '-buildTarget WSAPlayer -buildAppx' + $extraArgs += '-buildTarget WSAPlayer' } elseif ("${{ parameters.Platform }}" -eq "Standalone") { @@ -106,45 +106,7 @@ steps: Write-Output 'Unity Player Log Missing!' } - # The NuGet and AppX logs are only relevant for UWP builds. - if ("${{ parameters.Platform }}" -eq "UWP") - { - $nugetRestoreLogFileName = "$logDirectory\nugetRestore.log" - if (Test-Path $nugetRestoreLogFileName) - { - Write-Output '=====================================================' - Write-Output ' Begin NuGet Restore Log ' - Write-Output '=====================================================' - - Get-Content $nugetRestoreLogFileName - - Write-Output '=====================================================' - Write-Output ' End NuGet Restore Log ' - Write-Output '=====================================================' - } - else - { - Write-Output "NuGet Restore Log Missing $nugetRestoreLogFileName!" - } - - $appxBuildLogFileName = "$logDirectory\buildAppx.log" - if (Test-Path $appxBuildLogFileName) - { - Write-Output '=====================================================' - Write-Output ' Begin AppX Build Log ' - Write-Output '=====================================================' - - Get-Content $appxBuildLogFileName - - Write-Output '=====================================================' - Write-Output ' End AppX Build Log ' - Write-Output '=====================================================' - } - else - { - Write-Output "AppX Build Log Missing $appxBuildLogFileName!" - } - } + if ($proc.ExitCode -ne 0) { @@ -168,8 +130,8 @@ steps: # The final location of the generated package depends on the type of scripting backend it's built against. # For the default scripting backend (IL2CPP) the naming of the appx follows the form below: ${{ if eq(parameters.ScriptingBackend, 'default') }}: - PathtoPublish: '$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}\AppPackages\MixedRealityToolkit\MixedRealityToolkit_$(MRTKVersion).0_${{ parameters.PackagingDir }}_Master_Test' + PathToPublish: '$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}\AppPackages\MixedRealityToolkit\MixedRealityToolkit_$(MRTKVersion).0_${{ parameters.PackagingDir }}_Master_Test' # For .NET scripting backends, the naming is slightly different (mainly the AppPackages and MixedRealityToolkit folder # names are reversed, and the Architecture is part of the AppX name) ${{ if eq(parameters.ScriptingBackend, '.NET') }}: - PathtoPublish: '$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}\MixedRealityToolkit\AppPackages\MixedRealityToolkit_$(MRTKVersion).0_${{ parameters.Arch }}_Master_Test' + PathToPublish: '$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}\MixedRealityToolkit\AppPackages\MixedRealityToolkit_$(MRTKVersion).0_${{ parameters.Arch }}_Master_Test' diff --git a/scripts/packaging/createupmpackages.ps1 b/scripts/packaging/createupmpackages.ps1 index d0ac7da5e3a..6df6a9ba9a0 100644 --- a/scripts/packaging/createupmpackages.ps1 +++ b/scripts/packaging/createupmpackages.ps1 @@ -18,24 +18,23 @@ Add this switch if ProjectRoot represents a folder with existing tarballs to be patched and repacked. #> param( + [Parameter(Mandatory = $true)] [string]$ProjectRoot, + [string]$OutputDirectory = "./artifacts/upm", - [ValidatePattern("^\d+\.\d+\.\d+-?[a-zA-Z0-9\.]*$")] + + [Parameter(Mandatory = $true)] + [ValidatePattern("^\d+\.\d+\.\d+$")] [string]$Version, + [ValidatePattern("^\d+?[\.\d+]*$")] [string]$PreviewNumber, + [switch]$Repack ) -if (-not $ProjectRoot) { - throw "Missing required parameter: -ProjectRoot." -} $ProjectRoot = Resolve-Path -Path $ProjectRoot -if (-not $Version) { - throw "Missing required parameter: -Version." -} - if ($PreviewNumber) { $Version = "$Version-preview.$PreviewNumber" } @@ -54,8 +53,8 @@ $product = "toolkit" # This hashtable contains mappings of the packages (by name) to the folder which contains # the package contents. # -# The keys of this hashtable will be combined with the scope and product to create the -# final name of the package (for example, com.microsoft.mixedreality.toolkit.foundation +# The keys of this hashtable will be combined with the scope and product to create the +# final name of the package (for example, com.microsoft.mixedreality.toolkit.foundation # will use the packaging file contained in the folder associated with the foundation key). # # Note that capitalization below in the key itself is significant. Capitalization @@ -63,12 +62,12 @@ $product = "toolkit" # # These paths are ProjectRoot relative. $packages = [ordered]@{ - "foundation" = "Assets/MRTK"; + "foundation" = "Assets/MRTK"; "standardassets" = "Assets/MRTK/StandardAssets"; - "extensions" = "Assets/MRTK/Extensions"; - "tools" = "Assets/MRTK/Tools"; - "testutilities" = "Assets/MRTK/Tests/TestUtilities"; - "examples" = "Assets/MRTK/Examples"; + "extensions" = "Assets/MRTK/Extensions"; + "tools" = "Assets/MRTK/Tools"; + "testutilities" = "Assets/MRTK/Tests/TestUtilities"; + "examples" = "Assets/MRTK/Examples"; } # Beginning of the upm packaging script main section @@ -185,7 +184,7 @@ foreach ($entry in $packages.GetEnumerator()) { # A samples folder was created. Remove it. Remove-Item -Path $samplesFolder -Recurse -Force } - + if ($packageName -eq "foundation") { # The foundation package MOVES some content around. This restores the moved files. Start-Process -FilePath "git" -ArgumentList "checkout */Services/SceneSystem/SceneSystemResources*" -NoNewWindow -Wait From 18a7d842adf31b7f7648c5dfde4cc3222d6b299a Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 22 Mar 2022 15:13:30 -0700 Subject: [PATCH 02/14] Remove buildUWPDotNet --- pipelines/pr-2020.yaml | 1 - pipelines/pr.yaml | 2 -- pipelines/templates/ci-common.yml | 1 - pipelines/templates/common.yml | 10 ---------- 4 files changed, 14 deletions(-) diff --git a/pipelines/pr-2020.yaml b/pipelines/pr-2020.yaml index 6c5f317fe36..e5d008b755a 100644 --- a/pipelines/pr-2020.yaml +++ b/pipelines/pr-2020.yaml @@ -26,7 +26,6 @@ jobs: # WMR APIs, buildUWPArm would be a good candidate to re-enable) buildUWPX86: false buildUWPArm: false - buildUWPDotNet: false UnityVersion: $(Unity2020Version) - template: templates/end.yml diff --git a/pipelines/pr.yaml b/pipelines/pr.yaml index 7b1668c518b..67a6ff6bac9 100644 --- a/pipelines/pr.yaml +++ b/pipelines/pr.yaml @@ -25,7 +25,6 @@ jobs: # WMR APIs, buildUWPArm would be a good candidate to re-enable) buildUWPX86: false buildUWPArm: false - buildUWPDotNet: false UnityVersion: $(Unity2018Version) - job: Unity2019Validation @@ -42,6 +41,5 @@ jobs: parameters: buildUWPX86: false buildUWPArm: false - buildUWPDotNet: false UnityVersion: $(Unity2019Version) - template: templates/end.yml diff --git a/pipelines/templates/ci-common.yml b/pipelines/templates/ci-common.yml index 94750061d3b..57da2d1eb67 100644 --- a/pipelines/templates/ci-common.yml +++ b/pipelines/templates/ci-common.yml @@ -9,7 +9,6 @@ parameters: steps: - template: common.yml parameters: - buildUWPDotNet: false UnityVersion: ${{ parameters.UnityVersion }} - template: tasks/versionmetadata.yml - ${{ if eq(parameters.packagingEnabled, true) }}: diff --git a/pipelines/templates/common.yml b/pipelines/templates/common.yml index cfdf221a801..80e9fb2b5aa 100644 --- a/pipelines/templates/common.yml +++ b/pipelines/templates/common.yml @@ -4,7 +4,6 @@ parameters: UnityVersion: "" buildStandalone: true buildUWPArm: true - buildUWPDotNet: true buildUWPX86: true runTests: true @@ -46,12 +45,3 @@ steps: PackagingDir: 'ARM' UnityVersion: ${{ parameters.UnityVersion }} -# Build UWP x86 .NET backend -- ${{ if eq(parameters.buildUWPDotNet, true) }}: - - template: tasks/unitybuild.yml - parameters: - Arch: 'x86' - Platform: 'UWP' - PublishArtifacts: true - ScriptingBackend: '.NET' - UnityVersion: ${{ parameters.UnityVersion }} From 02eac0e19bb2d5451e2a3e2be77d6e7ac9f9addd Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 22 Mar 2022 15:20:46 -0700 Subject: [PATCH 03/14] buildUWPX86 -> buildUWPx86 --- pipelines/pr-2020.yaml | 2 +- pipelines/pr.yaml | 4 ++-- pipelines/templates/common.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pipelines/pr-2020.yaml b/pipelines/pr-2020.yaml index e5d008b755a..49594f58fae 100644 --- a/pipelines/pr-2020.yaml +++ b/pipelines/pr-2020.yaml @@ -24,7 +24,7 @@ jobs: # the specific flavors below that are experiencing failures in CI (for example, # if we're actively working on features that have a lot of churn on underlying # WMR APIs, buildUWPArm would be a good candidate to re-enable) - buildUWPX86: false + buildUWPx86: false buildUWPArm: false UnityVersion: $(Unity2020Version) diff --git a/pipelines/pr.yaml b/pipelines/pr.yaml index 67a6ff6bac9..6e1861c7486 100644 --- a/pipelines/pr.yaml +++ b/pipelines/pr.yaml @@ -23,7 +23,7 @@ jobs: # the specific flavors below that are experiencing failures in CI (for example, # if we're actively working on features that have a lot of churn on underlying # WMR APIs, buildUWPArm would be a good candidate to re-enable) - buildUWPX86: false + buildUWPx86: false buildUWPArm: false UnityVersion: $(Unity2018Version) @@ -39,7 +39,7 @@ jobs: steps: - template: templates/common.yml parameters: - buildUWPX86: false + buildUWPx86: false buildUWPArm: false UnityVersion: $(Unity2019Version) - template: templates/end.yml diff --git a/pipelines/templates/common.yml b/pipelines/templates/common.yml index 80e9fb2b5aa..35eca8cfa18 100644 --- a/pipelines/templates/common.yml +++ b/pipelines/templates/common.yml @@ -4,7 +4,7 @@ parameters: UnityVersion: "" buildStandalone: true buildUWPArm: true - buildUWPX86: true + buildUWPx86: true runTests: true steps: From a02532c03ff55680bbdeeadc3577f978d4ce41a6 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 22 Mar 2022 15:56:46 -0700 Subject: [PATCH 04/14] Refactor out build helpers Update build-appx.yaml --- pipelines/templates/common-Unity2019.yml | 24 +++- pipelines/templates/common.yml | 68 ++++++++--- pipelines/templates/tasks/build-appx.yml | 73 ++++-------- pipelines/templates/tasks/build-unity.yml | 88 ++++---------- pipelines/templates/tasks/unitybuild.yml | 137 ---------------------- 5 files changed, 116 insertions(+), 274 deletions(-) delete mode 100644 pipelines/templates/tasks/unitybuild.yml diff --git a/pipelines/templates/common-Unity2019.yml b/pipelines/templates/common-Unity2019.yml index 6364a5225bb..10eb0d31b37 100644 --- a/pipelines/templates/common-Unity2019.yml +++ b/pipelines/templates/common-Unity2019.yml @@ -5,13 +5,27 @@ parameters: steps: # Build UWP ARM64. -- template: tasks/unitybuild.yml +- template: tasks/build-unity.yml parameters: - Arch: 'arm64' - Platform: 'UWP' - PackagingDir: 'ARM64' UnityVersion: ${{ parameters.UnityVersion }} - PublishArtifacts: true + BuildTarget: WSAPlayer + CommandLineBuildMethod: Microsoft.MixedReality.Toolkit.Build.Editor.UnityPlayerBuildTools.StartCommandLineBuild + PathToProject: $(Build.Repository.LocalPath) + OutputPath: $(Agent.TempDirectory)/build/uwp + AdditionalArguments: -sceneList "Assets/MRTK/Examples/Demos/HandTracking/Scenes/HandInteractionExamples.unity" + +- template: tasks/build-appx.yml + parameters: + ProjectName: ${{ parameters.ProjectName }} + Architectures: [ARM64] + BuildFolderPath: $(Agent.TempDirectory)/build/uwp + OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm64 + +- task: PublishBuildArtifacts@1 + displayName: Publish UWP ARM64 + inputs: + ArtifactName: mrtk-build-arm64 + PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm64 - template: tests.yml parameters: diff --git a/pipelines/templates/common.yml b/pipelines/templates/common.yml index 35eca8cfa18..bd62116671a 100644 --- a/pipelines/templates/common.yml +++ b/pipelines/templates/common.yml @@ -13,11 +13,14 @@ steps: # to get run, Unity will hang showing a dialog (even when in batch mode). # This is the fastest build, since it doesn't produce an AppX. - ${{ if eq(parameters.buildStandalone, true) }}: - - template: tasks/unitybuild.yml + - template: tasks/build-unity.yml parameters: - Arch: 'x64' - Platform: 'Standalone' UnityVersion: ${{ parameters.UnityVersion }} + BuildTarget: StandaloneWindows64 + CommandLineBuildMethod: Microsoft.MixedReality.Toolkit.Build.Editor.UnityPlayerBuildTools.StartCommandLineBuild + PathToProject: $(Build.Repository.LocalPath) + OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-exe-x64/MixedRealityToolkit.exe + AdditionalArguments: -sceneList Assets/MRTK/Examples/Demos/HandTracking/Scenes/HandInteractionExamples.unity # Tests should run earlier in the process, so that engineers can get test failure # notifications earlier in the CI process. @@ -26,22 +29,51 @@ steps: parameters: UnityVersion: ${{ parameters.UnityVersion }} -# Build UWP x86 -- ${{ if eq(parameters.buildUWPX86, true) }}: - - template: tasks/unitybuild.yml +# Build UWP. +- ${{ if or(eq(parameters.buildUWPx86, true), eq(parameters.buildUWPArm, true)) }}: + - template: tasks/build-unity.yml parameters: - Arch: 'x86' - Platform: 'UWP' - PublishArtifacts: true UnityVersion: ${{ parameters.UnityVersion }} + BuildTarget: WSAPlayer + CommandLineBuildMethod: Microsoft.MixedReality.Toolkit.Build.Editor.UnityPlayerBuildTools.StartCommandLineBuild + PathToProject: $(Build.Repository.LocalPath) + OutputPath: $(Agent.TempDirectory)/build/uwp + AdditionalArguments: -sceneList Assets/MRTK/Examples/Demos/HandTracking/Scenes/HandInteractionExamples.unity -# Build UWP ARM -- ${{ if eq(parameters.buildUWPArm, true) }}: - - template: tasks/unitybuild.yml - parameters: - Arch: 'arm' - Platform: 'UWP' - PublishArtifacts: true - PackagingDir: 'ARM' - UnityVersion: ${{ parameters.UnityVersion }} + - task: PowerShell@2 + displayName: Validate build logs + inputs: + targetType: filePath + filePath: ./scripts/ci/validatebuildlog.ps1 + arguments: > + -LogFile $(Join-Path $(Agent.TempDirectory) "build_WSAPlayer.log") + + # Build UWP x86. + - ${{ if eq(parameters.buildUWPx86, true) }}: + - template: tasks/build-appx.yml + parameters: + ProjectName: MixedRealityToolkit + Architectures: [x86] + BuildFolderPath: $(Agent.TempDirectory)/build/uwp + OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-x86 + + - task: PublishBuildArtifacts@1 + displayName: Publish UWP x86 + inputs: + ArtifactName: mrtk-build-x86 + PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-x86 + + # Build UWP ARM. + - ${{ if eq(parameters.buildUWPArm, true) }}: + - template: tasks/build-appx.yml + parameters: + ProjectName: MixedRealityToolkit + Architectures: [ARM] + BuildFolderPath: $(Agent.TempDirectory)/build/uwp + OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm + - task: PublishBuildArtifacts@1 + displayName: Publish UWP ARM + inputs: + ArtifactName: mrtk-build-arm + PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm diff --git a/pipelines/templates/tasks/build-appx.yml b/pipelines/templates/tasks/build-appx.yml index e4fa2d601dc..bb7429abe4d 100644 --- a/pipelines/templates/tasks/build-appx.yml +++ b/pipelines/templates/tasks/build-appx.yml @@ -1,59 +1,30 @@ # [Template] Build appx from a Unity-built sln. parameters: -- name: PathToSolution +- name: ProjectName type: string - default: $(Build.SourcesDirectory)/TestProjects/Main -- name: Arch - type: string - values: - - x86 - - x64 - - arm - - arm64 - -steps: -- task: MSBuild@1 - displayName: Build UWP ${{ parameters.Arch }} AppX - inputs: - solution: ${{ parameters.PathToSolution }} - platform: ${{ parameters.Arch }} - configuration: Master - - -- powershell: | - $nugetRestoreLogFileName = "$logDirectory\nugetRestore.log" - if (Test-Path $nugetRestoreLogFileName) - { - Write-Output '=====================================================' - Write-Output ' Begin NuGet Restore Log ' - Write-Output '=====================================================' - Get-Content $nugetRestoreLogFileName +- name: Architectures + type: object + default: [] - Write-Output '=====================================================' - Write-Output ' End NuGet Restore Log ' - Write-Output '=====================================================' - } - else - { - Write-Output "NuGet Restore Log Missing $nugetRestoreLogFileName!" - } - - $appxBuildLogFileName = "$logDirectory\buildAppx.log" - if (Test-Path $appxBuildLogFileName) - { - Write-Output '=====================================================' - Write-Output ' Begin AppX Build Log ' - Write-Output '=====================================================' +- name: BuildFolderPath + type: string - Get-Content $appxBuildLogFileName +- name: OutputPath + type: string - Write-Output '=====================================================' - Write-Output ' End AppX Build Log ' - Write-Output '=====================================================' - } - else - { - Write-Output "AppX Build Log Missing $appxBuildLogFileName!" - } \ No newline at end of file +steps: +- ${{ each arch in parameters.Architectures }}: + - task: MSBuild@1 + displayName: Build ${{ arch }} AppX + inputs: + solution: ${{ parameters.BuildFolderPath }}/${{ parameters.ProjectName }}.sln + platform: ${{ arch }} + configuration: Master + + - task: CopyFiles@2 + displayName: Copy ${{ arch }} AppX to ${{ parameters.OutputPath }} + inputs: + sourceFolder: ${{ parameters.BuildFolderPath }}/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_$(MRTKVersion).0_${{ arch }}_Master_Test + targetFolder: ${{ parameters.OutputPath }} diff --git a/pipelines/templates/tasks/build-unity.yml b/pipelines/templates/tasks/build-unity.yml index 79ca05a3bc6..1f55e0b08ee 100644 --- a/pipelines/templates/tasks/build-unity.yml +++ b/pipelines/templates/tasks/build-unity.yml @@ -1,73 +1,35 @@ -# [Template] Compile MRTK inside Unity. +# [Template] Build project inside Unity. parameters: -- name: Architectures - type: object - default: - - x86 - - ARM -- name: Platform - type: string - values: - - UWP - - Standalone -- name: PublishArtifacts - type: boolean - default: false - name: UnityVersion type: string -steps: -- powershell: Install-Module UnitySetup -Scope CurrentUser -Force - displayName: Install unitysetup.powershell - -- ${{ if eq(parameters.Platform, 'UWP') }}: - - powershell: | - $logFile = "build_uwp.log" - Start-UnityEditor -Project ${{ parameters.PathToProject }} -Version ${{ parameters.UnityVersion }} -ExecuteMethod Microsoft.MixedReality.Toolkit.Build.Editor.UnityPlayerBuildTools.StartCommandLineBuild -BatchMode -Quit -Wait -LogFile $logFile -BuildTarget WSAPlayer -OutputPath build/uwp -AdditionalArguments "-CacheServerIPAddress ${Env:COG-UnityCache-WUS2-01}" - if (Test-Path $logFile) - { - Get-Content $logFile - } - displayName: Build UWP +- name: BuildTarget + type: string + values: + - StandaloneWindows64 + - WSAPlayer + - Android - - task: PowerShell@2 - displayName: Validate build logs - inputs: - targetType: filePath - filePath: ./scripts/ci/validatebuildlog.ps1 - arguments: > - -LogFile: '$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}\build\build.log' +- name: CommandLineBuildMethod + type: string - - ${{ each arch in parameters.Architectures }}: - - task: MSBuild@1 - displayName: Build UWP ${{ arch }} AppX - inputs: - solution: ${{ parameters.PathToProject }}/build/uwp/${{ parameters.ProjectName }}.sln - platform: ${{ arch }} - configuration: Master +- name: PathToProject + type: string - - task: CopyFiles@2 - displayName: Copy UWP ${{ arch }} AppX to artifacts staging directory - inputs: - sourceFolder: ${{ parameters.PathToProject }}/build/uwp/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_$(buildNumber).0_${{ arch }}_Master_Test - targetFolder: $(Build.ArtifactStagingDirectory)/Apps/uwp-${{ arch }} +- name: OutputPath + type: string -- ${{ if eq(parameters.Platform, 'Standalone') }}: - - ${{ each arch in parameters.Architectures }}: - - powershell: | - $logFile = "build_standalone_${{ arch }}.log" - Start-UnityEditor -Project ${{ parameters.PathToProject }} -Version ${{ parameters.UnityVersion }} -ExecuteMethod ${{ parameters.CommandLineBuildMethod }} -BatchMode -Quit -Wait -LogFile $logFile -BuildTarget StandaloneWindows64 -OutputPath build/standalone_${{ arch }}/${{ parameters.ProjectName }}.exe -AdditionalArguments "-CacheServerIPAddress ${Env:COG-UnityCache-WUS2-01}" - if (Test-Path $logFile) - { - Get-Content $logFile - } - displayName: Build StandaloneWindows64 +- name: AdditionalArguments + type: string + default: '' - - task: PowerShell@2 - displayName: Validate build logs - inputs: - targetType: filePath - filePath: ./scripts/ci/validatebuildlog.ps1 - arguments: > - -LogFile: '$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}\build\build.log' +steps: +- powershell: | + $logFile = Join-Path $(Agent.TempDirectory) "build_${{ parameters.BuildTarget }}.log" + Start-UnityEditor -Project ${{ parameters.PathToProject }} -Version ${{ parameters.UnityVersion }} -ExecuteMethod ${{ parameters.CommandLineBuildMethod }} -BatchMode -Quit -Wait -LogFile $logFile -BuildTarget ${{ parameters.BuildTarget }} -OutputPath ${{ parameters.OutputPath }} -AdditionalArguments "-CacheServerIPAddress ${Env:COG-UnityCache-WUS2-01} ${{ parameters.AdditionalArguments }}" + if (Test-Path $logFile) + { + Get-Content $logFile + } + displayName: Build ${{ parameters.BuildTarget }} diff --git a/pipelines/templates/tasks/unitybuild.yml b/pipelines/templates/tasks/unitybuild.yml deleted file mode 100644 index 1bb92b26cc3..00000000000 --- a/pipelines/templates/tasks/unitybuild.yml +++ /dev/null @@ -1,137 +0,0 @@ -# [Template] Compile MRTK inside Unity. - -parameters: -- name: Arch - type: string - values: - - x86 - - x64 - - arm - - arm64 -- name: Platform - type: string - values: - - UWP - - Standalone -- name: UnityArgs # [optional] additional args passed to Unity - type: string - default: none -- name: ScriptingBackend # [optional] - type: string - default: default - values: - - default - - .NET -- name: PublishArtifacts - type: boolean - default: false -- name: PackagingDir - type: string - default: Win32 -- name: UnityVersion - type: string - -steps: -- powershell: | - $UnityPath = ${Env:${{ parameters.UnityVersion }}} - # Find unity.exe as Start-UnityEditor currently doesn't support arbitrary parameters - $editor = Get-ChildItem $UnityPath -Filter 'Unity.exe' -Recurse | Select-Object -First 1 -ExpandProperty FullName - - # The build output goes to a unique combination of Platform + Arch + ScriptingBackend to ensure that - # each build will have a fresh destination folder. - $outDir = "$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}" - $logFile = New-Item -Path "$outDir\build\build.log" -ItemType File -Force - $logDirectory = "$outDir\logs" - - $sceneList = "Assets\MRTK\Examples\Demos\HandTracking\Scenes\HandInteractionExamples.unity" - - $extraArgs = "" - if ("${{ parameters.Platform }}" -eq "UWP") - { - $extraArgs += '-buildTarget WSAPlayer' - } - elseif ("${{ parameters.Platform }}" -eq "Standalone") - { - $extraArgs += "-buildTarget StandaloneWindows" - - if ("${{ parameters.Arch }}" -eq "x64") - { - $extraArgs += "64" - } - } - - if ("${{ parameters.UnityArgs }}" -ne "none") - { - $extraArgs += " ${{ parameters.UnityArgs }}" - } - - if ("${{ parameters.ScriptingBackend }}" -eq ".NET") - { - $extraArgs += " -scriptingBackend 2" - } - - $proc = Start-Process -FilePath "$editor" -ArgumentList "-projectPath $(Get-Location) -executeMethod Microsoft.MixedReality.Toolkit.Build.Editor.UnityPlayerBuildTools.StartCommandLineBuild -sceneList $sceneList -logFile $($logFile.FullName) -batchMode -${{ parameters.Arch }} -buildOutput $outDir $extraArgs -CacheServerIPAddress ${Env:COG-UnityCache-WUS2-01} -logDirectory $logDirectory" -PassThru - $ljob = Start-Job -ScriptBlock { param($log) Get-Content "$log" -Wait } -ArgumentList $logFile.FullName - - while (-not $proc.HasExited -and $ljob.HasMoreData) - { - Receive-Job $ljob - Start-Sleep -Milliseconds 200 - } - Receive-Job $ljob - - Stop-Job $ljob - - Remove-Job $ljob - Stop-Process $proc - - Write-Output '=====================================================' - Write-Output ' Unity Build Player Finished ' - Write-Output '=====================================================' - - if (Test-Path $logFile.FullName) - { - Write-Output '=====================================================' - Write-Output ' Begin Unity Player Log ' - Write-Output '=====================================================' - - Get-Content $logFile.FullName - - Write-Output '=====================================================' - Write-Output ' End Unity Player Log ' - Write-Output '=====================================================' - } - else - { - Write-Output 'Unity Player Log Missing!' - } - - - - if ($proc.ExitCode -ne 0) - { - exit $proc.ExitCode - } - displayName: "Build ${{ parameters.Platform }} ${{ parameters.Arch }} ${{ parameters.ScriptingBackend }}" - -- task: PowerShell@2 - displayName: Validate build logs - inputs: - targetType: filePath - filePath: ./scripts/ci/validatebuildlog.ps1 - arguments: > - -LogFile: '$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}\build\build.log' - -- task: PublishBuildArtifacts@1 - enabled: ${{ parameters.PublishArtifacts }} - displayName: Publish ${{ parameters.Platform }} ${{ parameters.Arch }} (${{ parameters.PackagingDir }}) ${{ parameters.ScriptingBackend }} - inputs: - ArtifactName: 'mrtk-build-${{ parameters.Arch }}' - # The final location of the generated package depends on the type of scripting backend it's built against. - # For the default scripting backend (IL2CPP) the naming of the appx follows the form below: - ${{ if eq(parameters.ScriptingBackend, 'default') }}: - PathToPublish: '$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}\AppPackages\MixedRealityToolkit\MixedRealityToolkit_$(MRTKVersion).0_${{ parameters.PackagingDir }}_Master_Test' - # For .NET scripting backends, the naming is slightly different (mainly the AppPackages and MixedRealityToolkit folder - # names are reversed, and the Architecture is part of the AppX name) - ${{ if eq(parameters.ScriptingBackend, '.NET') }}: - PathToPublish: '$(Build.ArtifactStagingDirectory)\build\${{ parameters.Platform }}_${{ parameters.Arch }}_${{ parameters.ScriptingBackend }}\MixedRealityToolkit\AppPackages\MixedRealityToolkit_$(MRTKVersion).0_${{ parameters.Arch }}_Master_Test' From 92ab898900b221bc3fb5009796632c028688f794 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 22 Mar 2022 16:10:20 -0700 Subject: [PATCH 05/14] Add ARM64 to common.yml --- pipelines/ci-daily.yml | 4 +-- pipelines/pr-2020.yaml | 3 +-- pipelines/pr.yaml | 6 ++--- pipelines/templates/ci-common.yml | 3 +++ pipelines/templates/common-Unity2019.yml | 34 ------------------------ pipelines/templates/common.yml | 24 ++++++++++++++--- 6 files changed, 28 insertions(+), 46 deletions(-) delete mode 100644 pipelines/templates/common-Unity2019.yml diff --git a/pipelines/ci-daily.yml b/pipelines/ci-daily.yml index 46fe3e5f823..f85aafd8efd 100644 --- a/pipelines/ci-daily.yml +++ b/pipelines/ci-daily.yml @@ -16,10 +16,10 @@ jobs: - SDK_18362 -equals TRUE - VS2019 -equals TRUE steps: - - template: templates/common-Unity2019.yml + - template: templates/common.yml parameters: - packagingEnabled: false UnityVersion: $(Unity2019Version) + buildUWPArm64: true - job: Unity2018Validation timeoutInMinutes: 120 diff --git a/pipelines/pr-2020.yaml b/pipelines/pr-2020.yaml index 49594f58fae..47cf40ffea3 100644 --- a/pipelines/pr-2020.yaml +++ b/pipelines/pr-2020.yaml @@ -24,8 +24,7 @@ jobs: # the specific flavors below that are experiencing failures in CI (for example, # if we're actively working on features that have a lot of churn on underlying # WMR APIs, buildUWPArm would be a good candidate to re-enable) - buildUWPx86: false - buildUWPArm: false + buildStandalone: true UnityVersion: $(Unity2020Version) - template: templates/end.yml diff --git a/pipelines/pr.yaml b/pipelines/pr.yaml index 6e1861c7486..aee8d084244 100644 --- a/pipelines/pr.yaml +++ b/pipelines/pr.yaml @@ -23,8 +23,7 @@ jobs: # the specific flavors below that are experiencing failures in CI (for example, # if we're actively working on features that have a lot of churn on underlying # WMR APIs, buildUWPArm would be a good candidate to re-enable) - buildUWPx86: false - buildUWPArm: false + buildStandalone: true UnityVersion: $(Unity2018Version) - job: Unity2019Validation @@ -39,7 +38,6 @@ jobs: steps: - template: templates/common.yml parameters: - buildUWPx86: false - buildUWPArm: false + buildStandalone: true UnityVersion: $(Unity2019Version) - template: templates/end.yml diff --git a/pipelines/templates/ci-common.yml b/pipelines/templates/ci-common.yml index 57da2d1eb67..338b0fd7228 100644 --- a/pipelines/templates/ci-common.yml +++ b/pipelines/templates/ci-common.yml @@ -10,6 +10,9 @@ steps: - template: common.yml parameters: UnityVersion: ${{ parameters.UnityVersion }} + buildStandalone: true + buildUWPx86: true + buildUWPArm: true - template: tasks/versionmetadata.yml - ${{ if eq(parameters.packagingEnabled, true) }}: - ${{ if eq(parameters.packageNuGet, true) }}: diff --git a/pipelines/templates/common-Unity2019.yml b/pipelines/templates/common-Unity2019.yml deleted file mode 100644 index 10eb0d31b37..00000000000 --- a/pipelines/templates/common-Unity2019.yml +++ /dev/null @@ -1,34 +0,0 @@ -# [Template] Common build tasks shared between CI builds and PR validation. - -parameters: - UnityVersion: "" - -steps: -# Build UWP ARM64. -- template: tasks/build-unity.yml - parameters: - UnityVersion: ${{ parameters.UnityVersion }} - BuildTarget: WSAPlayer - CommandLineBuildMethod: Microsoft.MixedReality.Toolkit.Build.Editor.UnityPlayerBuildTools.StartCommandLineBuild - PathToProject: $(Build.Repository.LocalPath) - OutputPath: $(Agent.TempDirectory)/build/uwp - AdditionalArguments: -sceneList "Assets/MRTK/Examples/Demos/HandTracking/Scenes/HandInteractionExamples.unity" - -- template: tasks/build-appx.yml - parameters: - ProjectName: ${{ parameters.ProjectName }} - Architectures: [ARM64] - BuildFolderPath: $(Agent.TempDirectory)/build/uwp - OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm64 - -- task: PublishBuildArtifacts@1 - displayName: Publish UWP ARM64 - inputs: - ArtifactName: mrtk-build-arm64 - PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm64 - -- template: tests.yml - parameters: - UnityVersion: ${{ parameters.UnityVersion }} - -- template: end.yml diff --git a/pipelines/templates/common.yml b/pipelines/templates/common.yml index bd62116671a..60d405a2abc 100644 --- a/pipelines/templates/common.yml +++ b/pipelines/templates/common.yml @@ -2,9 +2,10 @@ parameters: UnityVersion: "" - buildStandalone: true - buildUWPArm: true - buildUWPx86: true + buildStandalone: false + buildUWPx86: false + buildUWPArm: false + buildUWPArm64: false runTests: true steps: @@ -30,7 +31,7 @@ steps: UnityVersion: ${{ parameters.UnityVersion }} # Build UWP. -- ${{ if or(eq(parameters.buildUWPx86, true), eq(parameters.buildUWPArm, true)) }}: +- ${{ if or(eq(parameters.buildUWPx86, true), eq(parameters.buildUWPArm, true), eq(parameters.buildUWPArm64, true)) }}: - template: tasks/build-unity.yml parameters: UnityVersion: ${{ parameters.UnityVersion }} @@ -77,3 +78,18 @@ steps: inputs: ArtifactName: mrtk-build-arm PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm + + # Build UWP ARM64. + - ${{ if eq(parameters.buildUWPArm64, true) }}: + - template: tasks/build-appx.yml + parameters: + ProjectName: MixedRealityToolkit + Architectures: [ARM64] + BuildFolderPath: $(Agent.TempDirectory)/build/uwp + OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm64 + + - task: PublishBuildArtifacts@1 + displayName: Publish UWP ARM64 + inputs: + ArtifactName: mrtk-build-arm64 + PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm64 From 746dbbd6823c2c3a597759e9280b9dba8fb6509f Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 22 Mar 2022 16:19:45 -0700 Subject: [PATCH 06/14] Ensure unitysetup.powershell is installed --- pipelines/templates/common.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pipelines/templates/common.yml b/pipelines/templates/common.yml index 60d405a2abc..954e16ed46c 100644 --- a/pipelines/templates/common.yml +++ b/pipelines/templates/common.yml @@ -9,6 +9,12 @@ parameters: runTests: true 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 + displayName: Install unitysetup.powershell + # Build Standalone x64. # This must happen before tests run, because if the build fails and tests attempt # to get run, Unity will hang showing a dialog (even when in batch mode). From 88b29bfecadffc0b5f7b84a6a29c77444e6f5951 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 22 Mar 2022 16:25:20 -0700 Subject: [PATCH 07/14] Refactor out unity.yaml --- pipelines/templates/common.yml | 30 +++++------------ .../tasks/{build-appx.yml => build-appx.yaml} | 0 .../{build-unity.yml => build-unity.yaml} | 0 pipelines/templates/unity.yaml | 33 +++++++++++++++++++ 4 files changed, 41 insertions(+), 22 deletions(-) rename pipelines/templates/tasks/{build-appx.yml => build-appx.yaml} (100%) rename pipelines/templates/tasks/{build-unity.yml => build-unity.yaml} (100%) create mode 100644 pipelines/templates/unity.yaml diff --git a/pipelines/templates/common.yml b/pipelines/templates/common.yml index 954e16ed46c..0a962d4e143 100644 --- a/pipelines/templates/common.yml +++ b/pipelines/templates/common.yml @@ -20,14 +20,11 @@ steps: # to get run, Unity will hang showing a dialog (even when in batch mode). # This is the fastest build, since it doesn't produce an AppX. - ${{ if eq(parameters.buildStandalone, true) }}: - - template: tasks/build-unity.yml + - template: unity.yaml parameters: UnityVersion: ${{ parameters.UnityVersion }} BuildTarget: StandaloneWindows64 - CommandLineBuildMethod: Microsoft.MixedReality.Toolkit.Build.Editor.UnityPlayerBuildTools.StartCommandLineBuild - PathToProject: $(Build.Repository.LocalPath) OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-exe-x64/MixedRealityToolkit.exe - AdditionalArguments: -sceneList Assets/MRTK/Examples/Demos/HandTracking/Scenes/HandInteractionExamples.unity # Tests should run earlier in the process, so that engineers can get test failure # notifications earlier in the CI process. @@ -38,26 +35,15 @@ steps: # Build UWP. - ${{ if or(eq(parameters.buildUWPx86, true), eq(parameters.buildUWPArm, true), eq(parameters.buildUWPArm64, true)) }}: - - template: tasks/build-unity.yml + - template: unity.yaml parameters: UnityVersion: ${{ parameters.UnityVersion }} BuildTarget: WSAPlayer - CommandLineBuildMethod: Microsoft.MixedReality.Toolkit.Build.Editor.UnityPlayerBuildTools.StartCommandLineBuild - PathToProject: $(Build.Repository.LocalPath) OutputPath: $(Agent.TempDirectory)/build/uwp - AdditionalArguments: -sceneList Assets/MRTK/Examples/Demos/HandTracking/Scenes/HandInteractionExamples.unity - - - task: PowerShell@2 - displayName: Validate build logs - inputs: - targetType: filePath - filePath: ./scripts/ci/validatebuildlog.ps1 - arguments: > - -LogFile $(Join-Path $(Agent.TempDirectory) "build_WSAPlayer.log") # Build UWP x86. - ${{ if eq(parameters.buildUWPx86, true) }}: - - template: tasks/build-appx.yml + - template: tasks/build-appx.yaml parameters: ProjectName: MixedRealityToolkit Architectures: [x86] @@ -65,14 +51,14 @@ steps: OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-x86 - task: PublishBuildArtifacts@1 - displayName: Publish UWP x86 + displayName: Publish x86 AppX inputs: ArtifactName: mrtk-build-x86 PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-x86 # Build UWP ARM. - ${{ if eq(parameters.buildUWPArm, true) }}: - - template: tasks/build-appx.yml + - template: tasks/build-appx.yaml parameters: ProjectName: MixedRealityToolkit Architectures: [ARM] @@ -80,14 +66,14 @@ steps: OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm - task: PublishBuildArtifacts@1 - displayName: Publish UWP ARM + displayName: Publish ARM AppX inputs: ArtifactName: mrtk-build-arm PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm # Build UWP ARM64. - ${{ if eq(parameters.buildUWPArm64, true) }}: - - template: tasks/build-appx.yml + - template: tasks/build-appx.yaml parameters: ProjectName: MixedRealityToolkit Architectures: [ARM64] @@ -95,7 +81,7 @@ steps: OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm64 - task: PublishBuildArtifacts@1 - displayName: Publish UWP ARM64 + displayName: Publish ARM64 AppX inputs: ArtifactName: mrtk-build-arm64 PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm64 diff --git a/pipelines/templates/tasks/build-appx.yml b/pipelines/templates/tasks/build-appx.yaml similarity index 100% rename from pipelines/templates/tasks/build-appx.yml rename to pipelines/templates/tasks/build-appx.yaml diff --git a/pipelines/templates/tasks/build-unity.yml b/pipelines/templates/tasks/build-unity.yaml similarity index 100% rename from pipelines/templates/tasks/build-unity.yml rename to pipelines/templates/tasks/build-unity.yaml diff --git a/pipelines/templates/unity.yaml b/pipelines/templates/unity.yaml new file mode 100644 index 00000000000..04724ea9192 --- /dev/null +++ b/pipelines/templates/unity.yaml @@ -0,0 +1,33 @@ +# [Template] Build project inside Unity. + +parameters: +- name: UnityVersion + type: string + +- name: BuildTarget + type: string + values: + - StandaloneWindows64 + - WSAPlayer + - Android + +- name: OutputPath + type: string + +steps: +- template: tasks/build-unity.yaml + parameters: + UnityVersion: ${{ parameters.UnityVersion }} + BuildTarget: ${{ parameters.BuildTarget }} + CommandLineBuildMethod: Microsoft.MixedReality.Toolkit.Build.Editor.UnityPlayerBuildTools.StartCommandLineBuild + PathToProject: $(Build.Repository.LocalPath) + OutputPath: ${{ parameters.OutputPath }} + AdditionalArguments: -sceneList Assets/MRTK/Examples/Demos/HandTracking/Scenes/HandInteractionExamples.unity + +- task: PowerShell@2 + displayName: Validate build logs + inputs: + targetType: filePath + filePath: ./scripts/ci/validatebuildlog.ps1 + arguments: > + -LogFile $(Join-Path $(Agent.TempDirectory) "build_${{ parameters.BuildTarget }}.log") From c091f9db497ae5be75cbd1e002c5b507cd7ba21b Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 22 Mar 2022 16:59:27 -0700 Subject: [PATCH 08/14] Print Unity logs as we go Like we used to do! --- pipelines/templates/tasks/build-unity.yaml | 37 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/pipelines/templates/tasks/build-unity.yaml b/pipelines/templates/tasks/build-unity.yaml index 1f55e0b08ee..08c3918534d 100644 --- a/pipelines/templates/tasks/build-unity.yaml +++ b/pipelines/templates/tasks/build-unity.yaml @@ -27,9 +27,38 @@ parameters: steps: - powershell: | $logFile = Join-Path $(Agent.TempDirectory) "build_${{ parameters.BuildTarget }}.log" - Start-UnityEditor -Project ${{ parameters.PathToProject }} -Version ${{ parameters.UnityVersion }} -ExecuteMethod ${{ parameters.CommandLineBuildMethod }} -BatchMode -Quit -Wait -LogFile $logFile -BuildTarget ${{ parameters.BuildTarget }} -OutputPath ${{ parameters.OutputPath }} -AdditionalArguments "-CacheServerIPAddress ${Env:COG-UnityCache-WUS2-01} ${{ parameters.AdditionalArguments }}" - if (Test-Path $logFile) - { - Get-Content $logFile + $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 + + while (-not $proc.HasExited -and $ljob.HasMoreData) { + Receive-Job $ljob + Start-Sleep -Milliseconds 200 + } + + Stop-Job $ljob + Remove-Job $ljob + Stop-Process $proc + + Write-Output '=====================================================' + Write-Output ' Unity Build Player Finished ' + Write-Output '=====================================================' + + if (Test-Path $logFile) { + Write-Output '=====================================================' + Write-Output ' Begin Unity Player Log ' + Write-Output '=====================================================' + + Get-Content $logFile + + Write-Output '=====================================================' + Write-Output ' End Unity Player Log ' + Write-Output '=====================================================' + } + else { + Write-Output 'Unity Player log missing!' + } + + if ($proc.ExitCode -ne 0) { + exit $proc.ExitCode } displayName: Build ${{ parameters.BuildTarget }} From bd821e2243e19a5e724877f6d19b9c7228a25572 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 22 Mar 2022 16:59:42 -0700 Subject: [PATCH 09/14] Revert some changes to build-appx --- pipelines/templates/common.yml | 9 +++------ pipelines/templates/tasks/build-appx.yaml | 7 ++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/pipelines/templates/common.yml b/pipelines/templates/common.yml index 0a962d4e143..4fb5f67cd6b 100644 --- a/pipelines/templates/common.yml +++ b/pipelines/templates/common.yml @@ -48,13 +48,12 @@ steps: ProjectName: MixedRealityToolkit Architectures: [x86] BuildFolderPath: $(Agent.TempDirectory)/build/uwp - OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-x86 - task: PublishBuildArtifacts@1 displayName: Publish x86 AppX inputs: ArtifactName: mrtk-build-x86 - PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-x86 + PathToPublish: $(Build.ArtifactStagingDirectory)/Apps/uwp-x86 # Build UWP ARM. - ${{ if eq(parameters.buildUWPArm, true) }}: @@ -63,13 +62,12 @@ steps: ProjectName: MixedRealityToolkit Architectures: [ARM] BuildFolderPath: $(Agent.TempDirectory)/build/uwp - OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm - task: PublishBuildArtifacts@1 displayName: Publish ARM AppX inputs: ArtifactName: mrtk-build-arm - PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm + PathToPublish: $(Build.ArtifactStagingDirectory)/Apps/uwp-arm # Build UWP ARM64. - ${{ if eq(parameters.buildUWPArm64, true) }}: @@ -78,10 +76,9 @@ steps: ProjectName: MixedRealityToolkit Architectures: [ARM64] BuildFolderPath: $(Agent.TempDirectory)/build/uwp - OutputPath: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm64 - task: PublishBuildArtifacts@1 displayName: Publish ARM64 AppX inputs: ArtifactName: mrtk-build-arm64 - PathToPublish: $(Build.ArtifactStagingDirectory)/mrtk-build-uwp-arm64 + PathToPublish: $(Build.ArtifactStagingDirectory)/Apps/uwp-arm64 diff --git a/pipelines/templates/tasks/build-appx.yaml b/pipelines/templates/tasks/build-appx.yaml index bb7429abe4d..6feae9b2ad5 100644 --- a/pipelines/templates/tasks/build-appx.yaml +++ b/pipelines/templates/tasks/build-appx.yaml @@ -11,9 +11,6 @@ parameters: - name: BuildFolderPath type: string -- name: OutputPath - type: string - steps: - ${{ each arch in parameters.Architectures }}: - task: MSBuild@1 @@ -24,7 +21,7 @@ steps: configuration: Master - task: CopyFiles@2 - displayName: Copy ${{ arch }} AppX to ${{ parameters.OutputPath }} + displayName: Copy ${{ arch }} AppX to artifacts staging directory inputs: sourceFolder: ${{ parameters.BuildFolderPath }}/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_$(MRTKVersion).0_${{ arch }}_Master_Test - targetFolder: ${{ parameters.OutputPath }} + targetFolder: $(Build.ArtifactStagingDirectory)/Apps/uwp-${{ arch }} From 5ee6d0e02baf175dc9cfc3c737047df72b743124 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Wed, 23 Mar 2022 13:12:35 -0700 Subject: [PATCH 10/14] Account for x86 == Win32 --- pipelines/templates/tasks/build-appx.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pipelines/templates/tasks/build-appx.yaml b/pipelines/templates/tasks/build-appx.yaml index 6feae9b2ad5..e78a2428ec6 100644 --- a/pipelines/templates/tasks/build-appx.yaml +++ b/pipelines/templates/tasks/build-appx.yaml @@ -23,5 +23,8 @@ steps: - task: CopyFiles@2 displayName: Copy ${{ arch }} AppX to artifacts staging directory inputs: - sourceFolder: ${{ parameters.BuildFolderPath }}/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_$(MRTKVersion).0_${{ arch }}_Master_Test + ${{ if eq(arch, 'x86') }}: + sourceFolder: ${{ parameters.BuildFolderPath }}/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_$(MRTKVersion).0_Win32_Master_Test + ${{ if not(eq(arch, 'x86')) }}: + sourceFolder: ${{ parameters.BuildFolderPath }}/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_$(MRTKVersion).0_${{ arch }}_Master_Test targetFolder: $(Build.ArtifactStagingDirectory)/Apps/uwp-${{ arch }} From 3fcb671626fab5f2ea90cc644e3e7a1637b3afc9 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Wed, 23 Mar 2022 13:58:11 -0700 Subject: [PATCH 11/14] Improve UnitySetup installation --- pipelines/templates/common.yml | 6 ++++-- pipelines/templates/tasks/assetretargeting.yml | 6 ++++-- pipelines/templates/tasks/build-appx.yaml | 3 +++ pipelines/templates/tasks/build-unity.yaml | 12 +++++++++++- pipelines/templates/tasks/generate-projects.yml | 6 ++++-- 5 files changed, 26 insertions(+), 7 deletions(-) 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: | From fe28fc947c8d6759bc3fd0bd10acc40bb6d2a5f6 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Wed, 6 Apr 2022 11:46:14 -0700 Subject: [PATCH 12/14] stash --- pipelines/templates/tasks/build-unity.yaml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pipelines/templates/tasks/build-unity.yaml b/pipelines/templates/tasks/build-unity.yaml index da26b7e08a7..7afbbd39ca0 100644 --- a/pipelines/templates/tasks/build-unity.yaml +++ b/pipelines/templates/tasks/build-unity.yaml @@ -28,14 +28,7 @@ parameters: default: '' steps: -- 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 - } - +- powershell: | $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 From 9e42d9a0cb7ea04e67bed85662ccdedd134b2544 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Thu, 23 Jun 2022 10:58:54 -0700 Subject: [PATCH 13/14] Update build-unity.yaml --- pipelines/templates/tasks/build-unity.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pipelines/templates/tasks/build-unity.yaml b/pipelines/templates/tasks/build-unity.yaml index 7afbbd39ca0..7fe018a00e4 100644 --- a/pipelines/templates/tasks/build-unity.yaml +++ b/pipelines/templates/tasks/build-unity.yaml @@ -30,7 +30,8 @@ parameters: steps: - powershell: | $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 }}" + New-Item -Path $logFile -ItemType File -Force + $proc = Start-UnityEditor -Project ${{ parameters.PathToProject }} -Version ${{ parameters.UnityVersion }} -ExecuteMethod ${{ parameters.CommandLineBuildMethod }} -BatchMode -Quit -PassThru -LogFile $logFile -BuildTarget ${{ parameters.BuildTarget }} -OutputPath ${{ parameters.OutputPath }} -AdditionalArguments "${{ parameters.AdditionalArguments }}" $ljob = Start-Job -ScriptBlock { param($log) Get-Content "$log" -Wait } -ArgumentList $logFile while (-not $proc.HasExited -and $ljob.HasMoreData) { From 9e5e09811b6d0a065a1814c14c01fa7c10bdea1d Mon Sep 17 00:00:00 2001 From: Kurtis Date: Thu, 23 Jun 2022 11:04:44 -0700 Subject: [PATCH 14/14] Update build-appx.yaml --- pipelines/templates/common.yml | 3 +++ pipelines/templates/tasks/build-appx.yaml | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pipelines/templates/common.yml b/pipelines/templates/common.yml index d97c514ad32..8d347695b22 100644 --- a/pipelines/templates/common.yml +++ b/pipelines/templates/common.yml @@ -50,6 +50,7 @@ steps: ProjectName: MixedRealityToolkit Architectures: [x86] BuildFolderPath: $(Agent.TempDirectory)/build/uwp + Version: $(MRTKVersion) - task: PublishBuildArtifacts@1 displayName: Publish x86 AppX @@ -64,6 +65,7 @@ steps: ProjectName: MixedRealityToolkit Architectures: [ARM] BuildFolderPath: $(Agent.TempDirectory)/build/uwp + Version: $(MRTKVersion) - task: PublishBuildArtifacts@1 displayName: Publish ARM AppX @@ -78,6 +80,7 @@ steps: ProjectName: MixedRealityToolkit Architectures: [ARM64] BuildFolderPath: $(Agent.TempDirectory)/build/uwp + Version: $(MRTKVersion) - task: PublishBuildArtifacts@1 displayName: Publish ARM64 AppX diff --git a/pipelines/templates/tasks/build-appx.yaml b/pipelines/templates/tasks/build-appx.yaml index 60ecad83704..b318e6fe936 100644 --- a/pipelines/templates/tasks/build-appx.yaml +++ b/pipelines/templates/tasks/build-appx.yaml @@ -14,6 +14,9 @@ parameters: - name: BuildFolderPath type: string +- name: Version + type: string + steps: - ${{ each arch in parameters.Architectures }}: - task: MSBuild@1 @@ -27,7 +30,7 @@ steps: displayName: Copy ${{ arch }} AppX to artifacts staging directory inputs: ${{ if eq(arch, 'x86') }}: - sourceFolder: ${{ parameters.BuildFolderPath }}/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_$(MRTKVersion).0_Win32_Master_Test + sourceFolder: ${{ parameters.BuildFolderPath }}/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_${{ parameters.Version }}.0_Win32_Master_Test ${{ if not(eq(arch, 'x86')) }}: - sourceFolder: ${{ parameters.BuildFolderPath }}/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_$(MRTKVersion).0_${{ arch }}_Master_Test + sourceFolder: ${{ parameters.BuildFolderPath }}/AppPackages/${{ parameters.ProjectName }}/${{ parameters.ProjectName }}_${{ parameters.Version }}.0_${{ arch }}_Master_Test targetFolder: $(Build.ArtifactStagingDirectory)/Apps/uwp-${{ arch }}