feat: add `-activeBuildProfile`
parent
c6c8236152
commit
a35da6ee30
|
@ -56,14 +56,20 @@ namespace UnityBuilderAction
|
||||||
// of either `UnityEditor.BuildPlayerOptions` or `UnityEditor.BuildPlayerWithProfileOptions`
|
// of either `UnityEditor.BuildPlayerOptions` or `UnityEditor.BuildPlayerWithProfileOptions`
|
||||||
dynamic buildPlayerOptions;
|
dynamic buildPlayerOptions;
|
||||||
|
|
||||||
if (options["customBuildProfile"] != "") {
|
if (options.TryGetValue("activeBuildProfile", out var buildProfilePath) && !string.IsNullOrEmpty(buildProfilePath)) {
|
||||||
|
|
||||||
#if UNITY_6000_0_OR_NEWER
|
#if UNITY_6000_0_OR_NEWER
|
||||||
// Load build profile from Assets folder
|
// Load build profile from Assets folder
|
||||||
BuildProfile buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(options["customBuildProfile"]);
|
var buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(buildProfilePath)
|
||||||
|
?? throw new Exception("Build profile file not found at path: " + buildProfilePath);
|
||||||
|
|
||||||
// Set it as active
|
#if !BUILD_PROFILE_LOADED
|
||||||
BuildProfile.SetActiveBuildProfile(buildProfile);
|
throw new Exception("Build profile's define symbol not present before script execution; shouldn't happen");
|
||||||
|
#endif // BUILD_PROFILE_LOADED
|
||||||
|
|
||||||
|
// no need to set active profile, as already set by `-activeBuildProfile` CLI argument
|
||||||
|
// BuildProfile.SetActiveBuildProfile(buildProfile);
|
||||||
|
Debug.Log($"build profile: {buildProfile.name}");
|
||||||
|
|
||||||
// Define BuildPlayerWithProfileOptions
|
// Define BuildPlayerWithProfileOptions
|
||||||
buildPlayerOptions = new BuildPlayerWithProfileOptions {
|
buildPlayerOptions = new BuildPlayerWithProfileOptions {
|
||||||
|
@ -71,12 +77,16 @@ namespace UnityBuilderAction
|
||||||
locationPathName = options["customBuildPath"],
|
locationPathName = options["customBuildPath"],
|
||||||
options = buildOptions,
|
options = buildOptions,
|
||||||
};
|
};
|
||||||
#else
|
#else // UNITY_6000_0_OR_NEWER
|
||||||
throw new Exception("Build profiles are not supported by this version of Unity (" + Application.unityVersion +")");
|
throw new Exception("Build profiles are not supported by this version of Unity (" + Application.unityVersion +")");
|
||||||
#endif
|
#endif // UNITY_6000_0_OR_NEWER
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
#if BUILD_PROFILE_LOADED
|
||||||
|
throw new Exception("Build profile's define symbol present; shouldn't happen");
|
||||||
|
#endif // BUILD_PROFILE_LOADED
|
||||||
|
|
||||||
// Gather values from project
|
// Gather values from project
|
||||||
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();
|
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,19 @@ namespace UnityBuilderAction.Input
|
||||||
EditorApplication.Exit(110);
|
EditorApplication.Exit(110);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if UNITY_6000_0_OR_NEWER
|
||||||
|
var buildProfileSupport = true;
|
||||||
|
#else
|
||||||
|
var buildProfileSupport = false;
|
||||||
|
#endif // UNITY_6000_0_OR_NEWER
|
||||||
|
|
||||||
|
string buildProfile;
|
||||||
|
if (buildProfileSupport && validatedOptions.TryGetValue("activeBuildProfile", out buildProfile)) {
|
||||||
|
if (validatedOptions.ContainsKey("buildTarget")) {
|
||||||
|
Console.WriteLine("Extra argument -buildTarget");
|
||||||
|
EditorApplication.Exit(122);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
string buildTarget;
|
string buildTarget;
|
||||||
if (!validatedOptions.TryGetValue("buildTarget", out buildTarget)) {
|
if (!validatedOptions.TryGetValue("buildTarget", out buildTarget)) {
|
||||||
Console.WriteLine("Missing argument -buildTarget");
|
Console.WriteLine("Missing argument -buildTarget");
|
||||||
|
@ -31,6 +44,7 @@ namespace UnityBuilderAction.Input
|
||||||
Console.WriteLine(buildTarget + " is not a defined " + typeof(BuildTarget).Name);
|
Console.WriteLine(buildTarget + " is not a defined " + typeof(BuildTarget).Name);
|
||||||
EditorApplication.Exit(121);
|
EditorApplication.Exit(121);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string customBuildPath;
|
string customBuildPath;
|
||||||
if (!validatedOptions.TryGetValue("customBuildPath", out customBuildPath)) {
|
if (!validatedOptions.TryGetValue("customBuildPath", out customBuildPath)) {
|
||||||
|
|
|
@ -153,10 +153,11 @@ echo ""
|
||||||
-password "$UNITY_PASSWORD" \
|
-password "$UNITY_PASSWORD" \
|
||||||
-customBuildName "$BUILD_NAME" \
|
-customBuildName "$BUILD_NAME" \
|
||||||
-projectPath "$UNITY_PROJECT_PATH" \
|
-projectPath "$UNITY_PROJECT_PATH" \
|
||||||
-buildTarget "$BUILD_TARGET" \
|
$( [ -z "$BUILD_PROFILE" ] && echo "-buildTarget $BUILD_TARGET") \
|
||||||
-customBuildTarget "$BUILD_TARGET" \
|
-customBuildTarget "$BUILD_TARGET" \
|
||||||
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
||||||
-customBuildProfile "$BUILD_PROFILE" \
|
-customBuildProfile "$BUILD_PROFILE" \
|
||||||
|
${BUILD_PROFILE:+-activeBuildProfile} ${BUILD_PROFILE:+"$BUILD_PROFILE"} \
|
||||||
-executeMethod "$BUILD_METHOD" \
|
-executeMethod "$BUILD_METHOD" \
|
||||||
-buildVersion "$VERSION" \
|
-buildVersion "$VERSION" \
|
||||||
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
||||||
|
|
|
@ -125,10 +125,11 @@ unity-editor \
|
||||||
$( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \
|
$( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \
|
||||||
-customBuildName "$BUILD_NAME" \
|
-customBuildName "$BUILD_NAME" \
|
||||||
-projectPath "$UNITY_PROJECT_PATH" \
|
-projectPath "$UNITY_PROJECT_PATH" \
|
||||||
-buildTarget "$BUILD_TARGET" \
|
$( [ -z "$BUILD_PROFILE" ] && echo "-buildTarget $BUILD_TARGET" ) \
|
||||||
-customBuildTarget "$BUILD_TARGET" \
|
-customBuildTarget "$BUILD_TARGET" \
|
||||||
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
||||||
-customBuildProfile "$BUILD_PROFILE" \
|
-customBuildProfile "$BUILD_PROFILE" \
|
||||||
|
${BUILD_PROFILE:+-activeBuildProfile} ${BUILD_PROFILE:+"$BUILD_PROFILE"} \
|
||||||
-executeMethod "$BUILD_METHOD" \
|
-executeMethod "$BUILD_METHOD" \
|
||||||
-buildVersion "$VERSION" \
|
-buildVersion "$VERSION" \
|
||||||
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
||||||
|
|
|
@ -166,7 +166,6 @@ $unityArgs = @(
|
||||||
"-customBuildName", "`"$Env:BUILD_NAME`"",
|
"-customBuildName", "`"$Env:BUILD_NAME`"",
|
||||||
"-projectPath", "`"$Env:UNITY_PROJECT_PATH`"",
|
"-projectPath", "`"$Env:UNITY_PROJECT_PATH`"",
|
||||||
"-executeMethod", "`"$Env:BUILD_METHOD`"",
|
"-executeMethod", "`"$Env:BUILD_METHOD`"",
|
||||||
"-buildTarget", "`"$Env:BUILD_TARGET`"",
|
|
||||||
"-customBuildTarget", "`"$Env:BUILD_TARGET`"",
|
"-customBuildTarget", "`"$Env:BUILD_TARGET`"",
|
||||||
"-customBuildPath", "`"$Env:CUSTOM_BUILD_PATH`"",
|
"-customBuildPath", "`"$Env:CUSTOM_BUILD_PATH`"",
|
||||||
"-customBuildProfile", "`"$Env:BUILD_PROFILE`"",
|
"-customBuildProfile", "`"$Env:BUILD_PROFILE`"",
|
||||||
|
@ -181,6 +180,13 @@ $unityArgs = @(
|
||||||
"-logfile", "-"
|
"-logfile", "-"
|
||||||
) + $customParametersArray
|
) + $customParametersArray
|
||||||
|
|
||||||
|
if (-not $Env:BUILD_PROFILE) {
|
||||||
|
$unityArgs += @("-buildTarget", $Env:BUILD_TARGET)
|
||||||
|
}
|
||||||
|
if ($Env:BUILD_PROFILE) {
|
||||||
|
$unityArgs += @("-activeBuildProfile", $Env:BUILD_PROFILE)
|
||||||
|
}
|
||||||
|
|
||||||
# Remove null items as that will fail the Start-Process call
|
# Remove null items as that will fail the Start-Process call
|
||||||
$unityArgs = $unityArgs | Where-Object { $_ -ne $null }
|
$unityArgs = $unityArgs | Where-Object { $_ -ne $null }
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,8 @@ MonoBehaviour:
|
||||||
rid: 200022742090383361
|
rid: 200022742090383361
|
||||||
m_OverrideGlobalSceneList: 0
|
m_OverrideGlobalSceneList: 0
|
||||||
m_Scenes: []
|
m_Scenes: []
|
||||||
m_ScriptingDefines: []
|
m_ScriptingDefines:
|
||||||
|
- BUILD_PROFILE_LOADED
|
||||||
m_PlayerSettingsYaml:
|
m_PlayerSettingsYaml:
|
||||||
m_Settings: []
|
m_Settings: []
|
||||||
references:
|
references:
|
||||||
|
|
Loading…
Reference in New Issue