示例#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);
        }
示例#2
0
 /// <summary>
 /// Get a clean result representing a failure.
 /// </summary>
 /// <param name="exception">The exception that was thrown.</param>
 /// <returns>A new clean result instance.</returns>
 public CleanResult Failure(Exception exception) => CleanResult.Failure(BuildPipeline, BuildConfiguration, exception);
示例#3
0
 /// <summary>
 /// Get a clean result representing a failure.
 /// </summary>
 /// <param name="reason">The reason of the failure.</param>
 /// <returns>A new clean result instance.</returns>
 public CleanResult Failure(string reason) => CleanResult.Failure(BuildPipeline, BuildConfiguration, reason);