Ejemplo n.º 1
0
        /// <summary>
        /// Clean the build result from building the build pipeline of this build configuration.
        /// </summary>
        /// <param name="config">The build configuration that was used to build this build pipeline.</param>
        public CleanResult Clean(BuildConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (EditorApplication.isCompiling)
            {
                throw new InvalidOperationException("Cleaning is not allowed while Unity is compiling.");
            }

            if (EditorUtility.scriptCompilationFailed)
            {
                throw new InvalidOperationException("Cleaning is not allowed because scripts have compile errors in the editor.");
            }

            CleanResult result = null;

            try
            {
                using (var context = new CleanContext(this, config))
                {
                    var startTime = DateTime.Now;
                    var timer     = Stopwatch.StartNew();
                    result = OnClean(context);
                    // Clean artifacts after OnClean, since OnClean might use artifacts to determine build directory
                    config.CleanBuildArtifact();
                    timer.Stop();

                    if (result != null)
                    {
                        result.StartTime = startTime;
                        result.Duration  = timer.Elapsed;
                    }
                }
            }
            catch (Exception exception)
            {
                result = CleanResult.Failure(this, config, exception);
            }
            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Provides implementation to clean files produced by the build of this build pipeline corresponding to the specified build configuration.
 /// </summary>
 /// <param name="context">The clean context for the scope of the clean operation.</param>
 /// <returns>A result describing if clean is successful or not</returns>
 protected abstract CleanResult OnClean(CleanContext context);