Exemplo n.º 1
0
        public override bool Execute()
        {
            var result  = new LoggerResult();
            var package = Package.Load(result, File.ItemSpec, new PackageLoadParameters()
            {
                AutoCompileProjects     = false,
                LoadAssemblyReferences  = false,
                AutoLoadTemporaryAssets = false,
            });

            foreach (var message in result.Messages)
            {
                if (message.Type >= LogMessageType.Error)
                {
                    Log.LogError(message.ToString());
                }
                else if (message.Type == LogMessageType.Warning)
                {
                    Log.LogWarning(message.ToString());
                }
                else
                {
                    Log.LogMessage(message.ToString());
                }
            }

            // If we have errors loading the package, exit
            if (result.HasErrors)
            {
                return(false);
            }

            // Override version with task SpecialVersion (if specified by user)
            if (!string.IsNullOrEmpty(SpecialVersion))
            {
                package.Meta.Version = new PackageVersion(package.Meta.Version.Version, SpecialVersion);
            }

            Log.LogMessage(MessageImportance.High, "Packaging [{0}] version [{1}]", package.Meta.Name, package.Meta.Version);

            // Build the package
            PackageArchive.Build(package);
            return(true);
        }
Exemplo n.º 2
0
        public override bool Execute()
        {
            var result  = new LoggerResult();
            var package = Package.Load(result, File.ItemSpec, new PackageLoadParameters()
            {
                AutoCompileProjects     = false,
                LoadAssemblyReferences  = false,
                AutoLoadTemporaryAssets = false,
            });

            foreach (var message in result.Messages)
            {
                if (message.Type >= LogMessageType.Error)
                {
                    Log.LogError(message.ToString());
                }
                else if (message.Type == LogMessageType.Warning)
                {
                    Log.LogWarning(message.ToString());
                }
                else
                {
                    Log.LogMessage(message.ToString());
                }
            }

            // If we have errors loading the package, exit
            if (result.HasErrors)
            {
                return(false);
            }

            Log.LogMessage(MessageImportance.High, "Packaging [{0}] version [{1}]", package.Meta.Name, package.Meta.Version);

            var log = new LoggerResult();

            // Build the package
            PackageArchive.Build(log, package);

            // Output log
            foreach (var message in log.Messages)
            {
                MessageImportance importance;
                switch (message.Type)
                {
                case LogMessageType.Debug:
                case LogMessageType.Verbose:
                    importance = MessageImportance.Low;
                    break;

                case LogMessageType.Info:
                    importance = MessageImportance.Normal;
                    break;

                case LogMessageType.Warning:
                case LogMessageType.Error:
                case LogMessageType.Fatal:
                    importance = MessageImportance.High;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                Log.LogMessage(importance, message.Text);
            }

            return(true);
        }