Skip to content

Commit

Permalink
v1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
FejZa committed Sep 27, 2024
1 parent 53d7af2 commit 07d4993
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.6]

### Added

- Added first version of build script inspired by current Build V3 script

## [1.0.5]

### Changed
Expand Down
133 changes: 131 additions & 2 deletions Editor/AzurePipelinesBuildTemplate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,133 @@
public static class AzurePipelinesBuildTemplate
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using UnityEditor.Android;


#if UNITY_2018_1_OR_NEWER
using UnityEditor.Build.Reporting;
#endif

public static class AzurePipelinesBuild
{
private const string OutputFileNameArgument = "outputFileName";
private const string OutputPathArgument = "outputPath";

public static void PerformBuild()
{
if (!Dinomite.AzurePipelines.Utilities.TryGetCommandLineArgumentValue(OutputPathArgument, out var locationPathName) ||
!Dinomite.AzurePipelines.Utilities.TryGetCommandLineArgumentValue(OutputFileNameArgument, out var outputFileName))
{
EditorApplication.Exit(1);
return;
}

AndroidExternalToolsSettings.jdkRootPath = null;
AndroidExternalToolsSettings.sdkRootPath = null;
AndroidExternalToolsSettings.ndkRootPath = null;
AndroidExternalToolsSettings.gradlePath = null;

try
{
EditorBuildSettingsScene[] editorConfiguredBuildScenes = EditorBuildSettings.scenes;
List<string> includedScenes = new List<string>();

for (int i = 0; i < editorConfiguredBuildScenes.Length; i++)
{
if (editorConfiguredBuildScenes[i].enabled == false)
continue;

includedScenes.Add(editorConfiguredBuildScenes[i].path);
}

#if UNITY_2018_1_OR_NEWER
BuildReport buildReport = default(BuildReport);
#else
string buildReport = "ERROR";
#endif

buildReport = BuildPipeline.BuildPlayer(new BuildPlayerOptions
{
scenes = includedScenes.ToArray(),
target = EditorUserBuildSettings.activeBuildTarget,
locationPathName = Path.Combine(locationPathName, GetBuildTargetOutputFileNameAndExtension(outputFileName)),
targetGroup = EditorUserBuildSettings.selectedBuildTargetGroup,
options = BuildOptions.None
});

#if UNITY_2018_1_OR_NEWER
switch (buildReport.summary.result)
{
case BuildResult.Succeeded:
EditorApplication.Exit(0);
break;
case BuildResult.Unknown:
case BuildResult.Failed:
case BuildResult.Cancelled:
default:
EditorApplication.Exit(1);
break;
}
#else
if (buildReport.StartsWith("Error"))
{
EditorApplication.Exit(1);
}
else
{
EditorApplication.Exit(0);
}
#endif
}
catch (Exception ex) when (ex is Exception)
{
Debug.Log("BUILD FAILED: " + ex.Message);
EditorApplication.Exit(1);
}
}

}
private static string GetBuildTargetOutputFileNameAndExtension(string outputFileName)
{
switch (EditorUserBuildSettings.activeBuildTarget)
{
case BuildTarget.Android:
return string.Format("{0}.apk", outputFileName);
case BuildTarget.StandaloneWindows64:
case BuildTarget.StandaloneWindows:
return string.Format("{0}.exe", outputFileName);
#if UNITY_2018_1_OR_NEWER
case BuildTarget.StandaloneOSX:
#endif
#if !UNITY_2017_3_OR_NEWER
case BuildTarget.StandaloneOSXIntel:
case BuildTarget.StandaloneOSXIntel64:
#endif
return string.Format("{0}.app", outputFileName);
case BuildTarget.iOS:
case BuildTarget.tvOS:
case BuildTarget.StandaloneLinux:
case BuildTarget.WebGL:
case BuildTarget.WSAPlayer:
case BuildTarget.StandaloneLinux64:
case BuildTarget.StandaloneLinuxUniversal:
#if !UNITY_2018_3_OR_NEWER
case BuildTarget.PSP2:
#endif
case BuildTarget.PS4:
case BuildTarget.XboxOne:
#if !UNITY_2017_3_OR_NEWER
case BuildTarget.SamsungTV:
#endif
#if !UNITY_2018_1_OR_NEWER
case BuildTarget.N3DS:
case BuildTarget.WiiU:
#endif
case BuildTarget.Switch:
case BuildTarget.NoTarget:
default:
return outputFileName;
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "games.dinomite.azurepipelines",
"displayName": "Dinomite.AzurePipelines",
"description": "A Unity package containing build scripts for use with the Unity Tools for Azure DevOps extension.",
"version": "1.0.5",
"version": "1.0.6",
"unity": "2018.0",
"author": "Dinomite",
"keywords": [
Expand Down

0 comments on commit 07d4993

Please sign in to comment.