Пример #1
0
        /// <inheritdoc />
        public override void Run()
        {
            try
            {
                PrintSettings(_backupSettings, "Saved settings:");

                InitArgs();

                if (IsBuildPipelineBusy())
                {
                    throw new Exception("BuildPipeline is busy.");
                }

                var report = BuildPlayer(Settings);

                PrintReport(report);

#if UNITY_2018_1_OR_NEWER
                if (report.summary.result != BuildResult.Succeeded)
                {
                    throw new Exception("Build failed!");
                }
#endif
            }
            finally
            {
                _backupSettings.Apply();

                PrintSettings(_backupSettings, "Reverted settings:");
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes the arguments used by this command.
        /// </summary>
        private void InitArgs()
        {
            // Set the build name if there is one.
            string buildName;

            if (!GetArgumentValue(Values.ARG_BUILD_NAME, out buildName))
            {
                buildName = Values.DEFAULT_BUILD_NAME;
            }

            // Set the build output path.
            Settings.OutputPath = GetOutputPath(buildName);

            // Set the levels to include in the build.
            Settings.Levels = GetEnabledScenes();

            // Set android only settings.
            if (Settings.TargetGroup == BuildTargetGroup.Android)
            {
                string androidSdkPath;
                if (GetArgumentValue(Values.ARG_ANDROID_SDK_PATH, out androidSdkPath))
                {
                    Settings.AndroidSdkPath = androidSdkPath;
                }

                string keyAliasName;
                if (GetArgumentValue(Values.ARG_ANDROID_KEY_ALIAS_NAME, out keyAliasName))
                {
                    Settings.AndroidKeyAliasName = keyAliasName;
                }

                string keyAliasPass;
                if (GetArgumentValue(Values.ARG_ANDROID_KEY_ALIAS_PASS, out keyAliasPass))
                {
                    Settings.AndroidKeyAliasPass = keyAliasPass;
                }

                string keyStoreName;
                if (GetArgumentValue(Values.ARG_ANDROID_KEY_STORE_NAME, out keyStoreName))
                {
                    Settings.AndroidKeyStoreName = keyStoreName;
                }

                string keyStorePass;
                if (GetArgumentValue(Values.ARG_ANDROID_KEY_STORE_PASS, out keyStorePass))
                {
                    Settings.AndroidKeyStorePass = keyStorePass;
                }
            }

            // Set the initial build option.
            Settings.Options = Values.DEFAULT_BUILD_OPTIONS;

            // Set additional build options to use in the build.
            if (HasArgument(Values.ARG_OPTION_DEVELOPMENT))
            {
                Settings.Options |= BuildOptions.Development;
            }

            if (HasArgument(Values.ARG_OPTION_ALLOW_DEBUGGING))
            {
                Settings.Options |= BuildOptions.AllowDebugging;
            }

            if (HasArgument(Values.ARG_OPTION_SYMLINK_LIBRARIES))
            {
                Settings.Options |= BuildOptions.SymlinkLibraries;
            }

            if (HasArgument(Values.ARG_OPTION_FORCE_ENABLE_ASSERTIONS))
            {
                Settings.Options |= BuildOptions.ForceEnableAssertions;
            }

            if (HasArgument(Values.ARG_OPTION_COMPRESS_WITH_LZ4))
            {
                Settings.Options |= BuildOptions.CompressWithLz4;
            }

#if UNITY_2017_2_OR_NEWER
            if (HasArgument(Values.ARG_OPTION_COMPRESS_WITH_LZ4_HC))
            {
                Settings.Options |= BuildOptions.CompressWithLz4HC;
            }
#endif

            if (HasArgument(Values.ARG_OPTION_STRICT_MODE))
            {
                Settings.Options |= BuildOptions.StrictMode;
            }

#if UNITY_2018_1_OR_NEWER
            if (HasArgument(Values.ARG_OPTION_INCLUDE_TEST_ASSEMBLIES))
            {
                Settings.Options |= BuildOptions.IncludeTestAssemblies;
            }
#endif

            // Set the application identifier if there is one.
            string applicationIdentifier;
            if (GetArgumentValue(Values.ARG_APPLICATION_IDENTIFIER, out applicationIdentifier))
            {
                Settings.ApplicationIdentifier = applicationIdentifier;
            }

            // Set the bundle version if there is one.
            string bundleVersion;
            if (GetArgumentValue(Values.ARG_BUNDLE_VERSION, out bundleVersion))
            {
                Settings.BundleVersion = bundleVersion;
            }

            // Apply the new settings.
            Settings.Apply();

            PrintSettings(Settings, "Overwrote settings:");
        }