Пример #1
0
        public static void BuildProject()
        {
            // Gather values from args
            var options = ArgumentsParser.GetValidatedOptions();

            // Gather values from project
            var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();

            // Define BuildPlayer Options
            var buildOptions = new BuildPlayerOptions {
                scenes           = scenes,
                locationPathName = options["customBuildPath"],
                target           = (BuildTarget)Enum.Parse(typeof(BuildTarget), options["buildTarget"]),
            };

            // Set version for this build
            VersionApplicator.SetVersion(options["version"]);

            // Perform build
            BuildReport buildReport = BuildPipeline.BuildPlayer(buildOptions);

            // Summary
            BuildSummary summary = buildReport.summary;

            StdOutReporter.ReportSummary(summary);

            // Result
            BuildResult result = summary.result;

            StdOutReporter.ExitWithResult(result);
        }
Пример #2
0
        static void UpdateVersion(VersionApplicator applicator, VersionUpdaterConfiguration config, Dictionary <string, string> properties, VersionType type)
        {
            var oldVersion = applicator.GetVersion(type);
            var newVersion = config.Update(oldVersion, properties);

            applicator.SetVersions(type, newVersion);
            Console.WriteLine("{2} version updated from {0} to {1}.", oldVersion, newVersion, type);
        }
Пример #3
0
        public static void BuildProject()
        {
            // Gather values from args
            var options = ArgumentsParser.GetValidatedOptions();

            // Gather values from project
            var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();

            // Get all buildOptions from options
            BuildOptions buildOptions = BuildOptions.None;

            foreach (string buildOptionString in Enum.GetNames(typeof(BuildOptions)))
            {
                if (options.ContainsKey(buildOptionString))
                {
                    BuildOptions buildOptionEnum = (BuildOptions)Enum.Parse(typeof(BuildOptions), buildOptionString);
                    buildOptions |= buildOptionEnum;
                }
            }

            // Define BuildPlayer Options
            var buildPlayerOptions = new BuildPlayerOptions {
                scenes           = scenes,
                locationPathName = options["customBuildPath"],
                target           = (BuildTarget)Enum.Parse(typeof(BuildTarget), options["buildTarget"]),
                options          = buildOptions
            };

            // Set version for this build
            VersionApplicator.SetVersion(options["buildVersion"]);
            VersionApplicator.SetAndroidVersionCode(options["androidVersionCode"]);

            // Apply Android settings
            if (buildPlayerOptions.target == BuildTarget.Android)
            {
                AndroidSettings.Apply(options);
            }

            // Execute default AddressableAsset content build, if the package is installed
#if USE_ADDRESSABLES
            AddressableAssetSettings.CleanPlayerContent();
            AddressableAssetSettings.BuildPlayerContent();
#endif

            // Perform build
            BuildReport buildReport = BuildPipeline.BuildPlayer(buildPlayerOptions);

            // Summary
            BuildSummary summary = buildReport.summary;
            StdOutReporter.ReportSummary(summary);

            // Result
            BuildResult result = summary.result;
            StdOutReporter.ExitWithResult(result);
        }
Пример #4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            var config = CreateVersionConfig(txtConfig.Text);

            var textVersion = string.Format("AssemblyVersion(\"{0}\")", txtVersion.Text);
            var applicator  = new VersionApplicator(textVersion);

            var version = applicator.GetVersion(VersionType.Assembly);

            version = config.Update(version, CreateProperties(txtProperties.Text));
            applicator.SetVersions(VersionType.Assembly, version);
            txtVersion.Text = applicator.GetVersion(VersionType.Assembly).ToString();
        }
Пример #5
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args">The arguments passed to the application.</param>
        static void Main(string[] args)
        {
            var definition = new ApplicationCommandLineDefinition();
            var parser     = new CommandLineParser();
            var options    = new ApplicationOptions();

            try {
                parser.Parse(definition, args, options);

                if (options.ShowHelp)
                {
                    Console.WriteLine(parser.GenerateHelpText(definition, "VersionUpdater", string.Empty));
                    Console.ReadLine();
                    return;
                }

                var config     = VersionUpdaterConfiguration.Load(options.ConfigFile);
                var applicator = new VersionApplicator(File.ReadAllText(options.InputFile));

                var properties = options.Properties;

                // Update the appropriate version numbers.
                if (options.Update == "both" || options.Update == "assembly")
                {
                    UpdateVersion(applicator, config, properties, VersionType.Assembly);
                }

                if (options.Update == "both" || options.Update == "file")
                {
                    UpdateVersion(applicator, config, properties, VersionType.File);
                }

                // Write the changes back.
                File.WriteAllText(options.InputFile, applicator.Source);
                Console.WriteLine("Versions written successfully.");
            } catch (Exception ex) {
                if (!options.ShowHelp)
                {
                    LogError("Unable to update version options:", ex);
                }
                Console.WriteLine(parser.GenerateHelpText(definition, "VersionUpdater", string.Empty));
                Console.ReadLine();
            }
        }
Пример #6
0
        public static void BuildProject()
        {
            // Gather values from args
            var options = ArgumentsParser.GetValidatedOptions();

            // Gather values from project
            var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();

            // Get all buildOptions from options
            BuildOptions buildOptions = BuildOptions.None;

            foreach (string buildOptionString in Enum.GetNames(typeof(BuildOptions)))
            {
                if (options.ContainsKey(buildOptionString))
                {
                    BuildOptions buildOptionEnum = (BuildOptions)Enum.Parse(typeof(BuildOptions), buildOptionString);
                    buildOptions |= buildOptionEnum;
                }
            }

            // Define BuildPlayer Options
            var buildPlayerOptions = new BuildPlayerOptions {
                scenes           = scenes,
                locationPathName = options["customBuildPath"],
                target           = (BuildTarget)Enum.Parse(typeof(BuildTarget), options["buildTarget"]),
                options          = buildOptions
            };

            // Set version for this build
            VersionApplicator.SetVersion(options["buildVersion"]);
            VersionApplicator.SetAndroidVersionCode(options["androidVersionCode"]);

            // Apply Android settings
            if (buildPlayerOptions.target == BuildTarget.Android)
            {
                AndroidSettings.Apply(options);
            }

            // Execute default AddressableAsset content build, if the package is installed.
            // Version defines would be the best solution here, but Unity 2018 doesn't support that,
            // so we fall back to using reflection instead.
            var addressableAssetSettingsType = Type.GetType(
                "UnityEditor.AddressableAssets.Settings.AddressableAssetSettings,Unity.Addressables.Editor");

            if (addressableAssetSettingsType != null)
            {
                // ReSharper disable once PossibleNullReferenceException, used from try-catch
                void CallAddressablesMethod(string methodName, object[] args) => addressableAssetSettingsType
                .GetMethod(methodName, BindingFlags.Static | BindingFlags.Public)
                .Invoke(null, args);

                try
                {
                    CallAddressablesMethod("CleanPlayerContent", new object[] { null });
                    CallAddressablesMethod("BuildPlayerContent", Array.Empty <object>());
                }
                catch (Exception e)
                {
                    Debug.LogError($"Failed to run default addressables build:\n{e}");
                }
            }

            // Perform build
            BuildReport buildReport = BuildPipeline.BuildPlayer(buildPlayerOptions);

            // Summary
            BuildSummary summary = buildReport.summary;

            StdOutReporter.ReportSummary(summary);

            // Result
            BuildResult result = summary.result;

            StdOutReporter.ExitWithResult(result);
        }