Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Last active November 6, 2019 14:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/a6afe45d635e7612cf947207a6bc855d to your computer and use it in GitHub Desktop.
Save guitarrapc/a6afe45d635e7612cf947207a6bc855d to your computer and use it in GitHub Desktop.
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'windows-2019'
# make sure you have set variables for followings at AzureDevOps Pipeline Variable configuration UI.
# https://dev.azure.com/YOUR_ORG/YOUR_PROJECT/_apps/hub/ms.vss-ciworkflow.build-ci-hub?_a=edit-build-definition&id=YOUR_ID&view=Tab_Variables
#variables:
#unity.username: YOUR_USER_NAME_AS_SECRET
#unity.password: YOUR_USER_PASSWORD_AS_SECRET
#unity.serialkey: YOUR_UNITY_SERIALKEY_AS_SECRET
steps:
- checkout: self
clean: true
fetchDepth: 1
lfs: false
# YAML Build not support output variable but you can get task output variable with `name` key.
# refer: https://developercommunity.visualstudio.com/content/problem/335706/output-variable-set-in-the-vsts-task-does-not-show.html
# use name instead to reference output variable.
- task: DinomiteStudios.64e90d50-a9c0-11e8-a356-d3eab7857116.custom-unity-get-project-version-task.UnityGetProjectVersionTask@1
displayName: 'Unity Get Project Version'
name: unitygetprojectversion
- pwsh: Install-Module -Name UnitySetup -AllowPrerelease -Scope CurrentUser -Force
displayName: 'Install UnitySetup Module'
failOnStderr: true
- pwsh: Install-UnitySetupInstance -Installers (Find-UnitySetupInstaller -Version '$(unitygetprojectversion.projectVersion)' -Components Windows,UWP_IL2CPP) -Verbose
displayName: 'Install Unity'
failOnStderr: true
- task: DinomiteStudios.64e90d50-a9c0-11e8-a356-d3eab7857116.custom-unity-activate-license-task.UnityActivateLicenseTask@1
displayName: 'Unity Activate License'
inputs:
username: '$(unity.username)'
password: '$(unity.password)'
serial: '$(unity.serialkey)'
- script: dotnet tool install --global UnityBuildRunner
displayName: 'Install UnityBuildRunner'
- script: |
set UnityPath=C:\Program Files\Unity\Hub\Editor\$(unitygetprojectversion.projectVersion)\Editor\Unity.exe
UnityBuildRunner -quit -batchmode -projectPath $(Build.Repository.LocalPath) -buildTarget WSAPlayer -logfile $(Build.ArtifactStagingDirectory)\Editor.log -executeMethod HoloToolkit.Unity.BuildDeployTools.BuildSLN
displayName: 'Unity Build'
# UnityBuildTask@2 could not show build status, and is failed to build....
# - task: DinomiteStudios.64e90d50-a9c0-11e8-a356-d3eab7857116.custom-unity-build-task.UnityBuildTask@2
# displayName: 'Unity Build WindowsStoreApps'
# inputs:
# buildTarget: WindowsStoreApps
# commandLineArgumentsMode: custom
# customCommandLineArguments: '-ExecuteMethod HoloToolkit.Unity.BuildDeployTools.BuildSLN -logfile $(Build.ArtifactStagingDirectory)/Editor.log'
# continueOnError: true
- task: PublishPipelineArtifact@0
displayName: 'Publish Pipeline Artifact'
inputs:
artifactName: 'unity_build_log'
targetPath: '$(Build.ArtifactStagingDirectory)'
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: 'UWP/*.sln'
# if you want to build locally
# - task: PublishPipelineArtifact@0
# displayName: 'Publish Pipeline Artifact'
# inputs:
# artifactName: 'UWP_Sln'
# targetPath: 'UWP'
- task: MSBuild@1
displayName: 'Build solution'
inputs:
solution: 'UWP'
platform: x86
configuration: Release
msbuildArguments: '/P:PlatformToolset=v142;AppxBundle=Always;AppxBundlePlatforms=x86'
- task: PublishPipelineArtifact@0
displayName: 'Publish Pipeline Artifact'
inputs:
artifactName: 'apppackages'
targetPath: 'UWP/AppPackages'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment