Ejemplo n.º 1
0
        public override void Run(IBuildContext context)
        {
            var project = context.LoadProject();

            context.Trace.TraceInformation(Msg.D1015, Texts.Writing_package_exports___);

            var fieldToWrite = context.Configuration.GetArray(Constants.Configuration.WriteExports.FieldsToWrite).Select(f => f.ToLowerInvariant()).ToList();
            var fileName     = PathHelper.Combine(context.ProjectDirectory, Configuration.GetString(Constants.Configuration.Output.Directory) + "\\" + context.Configuration.GetString(Constants.Configuration.WriteExports.FileName));

            FileSystem.CreateDirectoryFromFileName(fileName);

            using (var writer = FileSystem.OpenStreamWriter(fileName))
            {
                var defaultDatabase = context.Configuration.GetString(Constants.Configuration.Database, "master");

                using (var output = Factory.XmlWriter(writer))
                {
                    output.WriteStartElement("Exports");
                    output.WriteAttributeString("Database", defaultDatabase);

                    foreach (var template in project.Templates.Where(t => t.IsEmittable).OrderBy(t => t.ItemIdOrPath))
                    {
                        WriteAsExportXml(output, defaultDatabase, template);
                    }

                    foreach (var item in project.Items.Where(i => i.IsEmittable).OrderBy(i => i.ItemIdOrPath))
                    {
                        WriteAsExportXml(output, defaultDatabase, item, fieldToWrite);
                    }

                    output.WriteEndElement();
                }
            }
        }
        public override void Run(IBuildContext context)
        {
            var projectDirectory = context.Configuration.GetCommandLineArg(1);

            if (string.IsNullOrEmpty(projectDirectory))
            {
                context.Trace.WriteLine(Texts.Missing_project_directory_to_compare_with);
                return;
            }

            projectDirectory = PathHelper.Combine(Directory.GetCurrentDirectory(), projectDirectory);
            if (!FileSystem.DirectoryExists(projectDirectory))
            {
                context.Trace.WriteLine(Texts.Project_directory_not_found__ + projectDirectory);
                return;
            }

            var project1 = context.LoadProject();

            var project2 = ProjectService.LoadProjectFromNewHost(projectDirectory);

            if (project2 == null)
            {
                context.Trace.WriteLine(Texts.Could_not_load_project__ + projectDirectory);
                return;
            }

            Compare(context, project1, project2);
        }
        protected void ListOutput([NotNull] IBuildContext context)
        {
            var project = context.LoadProject();

            foreach (var item in project.Items.Where(i => !i.IsImport).OrderBy(i => i.ItemIdOrPath))
            {
                var text = item.ItemIdOrPath;
                if (string.IsNullOrEmpty(text))
                {
                    text = item.ItemName;
                }

                text += " [" + item.TemplateName + "]";

                if (string.IsNullOrEmpty(text))
                {
                    text = "? [Item]";
                }

                Console.WriteLine(text);
            }

            foreach (var filePath in project.Files.OrderBy(i => i.FilePath))
            {
                var fileName = filePath.FilePath;
                if (string.IsNullOrEmpty(fileName))
                {
                    continue;
                }

                Console.WriteLine(fileName);
            }
        }
Ejemplo n.º 4
0
        public override void Run(IBuildContext context)
        {
            var project = context.LoadProject();

            context.Trace.TraceInformation(Msg.C1041, Texts.Checking___);

            var treatWarningsAsErrors = context.Configuration.GetBool(Constants.Configuration.CheckProject.TreatWarningsAsErrors);

            var diagnostics = project.Diagnostics.ToArray();

            context.Trace.TraceDiagnostics(diagnostics, treatWarningsAsErrors);

            var errors        = diagnostics.Count(d => d.Severity == Severity.Error);
            var warnings      = diagnostics.Count(d => d.Severity == Severity.Warning);
            var messages      = diagnostics.Count(d => d.Severity == Severity.Information);
            var checkersCount = CheckerService.EnabledCheckersCount;
            var references    = project.ProjectItems.Sum(i => i.References.Count);

            if (treatWarningsAsErrors)
            {
                errors  += warnings;
                warnings = 0;
            }

            context.Trace.TraceInformation(Msg.C1042, $"Checks: {checkersCount}, references: {references}, errors: {errors}, warnings: {warnings}, messages: {messages}");

            if (context.Configuration.GetBool(Constants.Configuration.CheckProject.StopOnErrors, true) && errors > 0)
            {
                context.IsAborted = true;
            }
        }
        public override void Run(IBuildContext context)
        {
            context.Trace.TraceInformation(Msg.G1009, "Generating schemas...");

            var project = context.LoadProject();

            WriteJsonSchema(project);
            // WriteXmlSchema(project);
        }
        protected void ListTemplates([NotNull] IBuildContext context)
        {
            var project = context.LoadProject();

            foreach (var item in project.Templates.OrderBy(t => t.ItemIdOrPath))
            {
                context.Trace.WriteLine(item.ItemIdOrPath);
            }
        }
        protected void ListFiles([NotNull] IBuildContext context)
        {
            var project = context.LoadProject();

            foreach (var item in project.Files.OrderBy(file => file.FilePath))
            {
                context.Trace.WriteLine(item.FilePath);
            }
        }
Ejemplo n.º 8
0
        public override void Run(IBuildContext context)
        {
            var project = context.LoadProject();

            context.Trace.TraceInformation(Msg.G1009, Texts.Generating_code___);

            foreach (var codeGenerator in CodeGenerators)
            {
                codeGenerator.Generate(context, TextTemplatingEngine, project);
            }
        }
        protected void ListProject([NotNull] IBuildContext context)
        {
            var project = context.LoadProject();

            foreach (var projectItem in project.ProjectItems.OrderBy(i => i.GetType().Name))
            {
                var qualifiedName = projectItem.QualifiedName;

                if (projectItem is File)
                {
                    qualifiedName = "\\" + PathHelper.UnmapPath(project.ProjectDirectory, qualifiedName);
                }

                context.Trace.WriteLine($"{qualifiedName} ({projectItem.GetType().Name})");
            }
        }
Ejemplo n.º 10
0
        public override void Run(IBuildContext context)
        {
            var qualifiedName = context.Configuration.GetCommandLineArg(0);

            if (string.IsNullOrEmpty(qualifiedName))
            {
                context.Trace.WriteLine(Texts.You_must_specific_the___name_argument);
                return;
            }

            var project    = context.LoadProject();
            var references = GetUsages(project, qualifiedName).ToArray();

            Display(context, references);

            context.Trace.WriteLine(Texts.Found__ + references.Length);
        }
Ejemplo n.º 11
0
        public override void Run(IBuildContext context)
        {
            if (!context.IsProjectLoaded)
            {
                return;
            }

            var project = context.LoadProject();

            var items      = project.Items.Count();
            var templates  = project.Templates.Count();
            var renderings = project.ProjectItems.OfType <Rendering>().Count();
            var media      = project.ProjectItems.OfType <MediaFile>().Count();
            var files      = project.Files.Count();

            var diagnostics = project.Diagnostics.ToArray();

            var errors   = diagnostics.Count(d => d.Severity == Severity.Error);
            var warnings = diagnostics.Count(d => d.Severity == Severity.Warning);
            var messages = diagnostics.Count(d => d.Severity == Severity.Information);

            var treatWarningsAsErrors = context.Configuration.GetBool(Constants.Configuration.CheckProject.TreatWarningsAsErrors);

            if (treatWarningsAsErrors)
            {
                errors  += warnings;
                warnings = 0;
            }

            context.Trace.WriteLine($"Project metrics: {items} items, {templates} templates, {media} media files, {renderings} renderings, {files} files, {errors} errors, {warnings} warnings, {messages} messages");

            context.ErrorCode = project.Diagnostics.Any(d => d.Severity == Severity.Warning || d.Severity == Severity.Error) ? 1 : 0;

            if (Host.Stopwatch != null)
            {
                Host.Stopwatch.Stop();
                Console.Write(Texts.Time___0_ms, Host.Stopwatch.Elapsed.TotalMilliseconds.ToString("#,##0"));
                Console.Write(@", ");
            }

            Console.Write(Texts.Ducats___0_, project.Ducats.ToString("#,##0"));
            Console.WriteLine();
        }
Ejemplo n.º 12
0
        public override void Run(IBuildContext context)
        {
            var qualifiedName = context.Configuration.GetCommandLineArg(0);

            if (string.IsNullOrEmpty(qualifiedName))
            {
                context.Trace.WriteLine(Texts.You_must_specific_the___name_argument);
                return;
            }

            var project = context.LoadProject();

            var projectItem = project.Indexes.FindQualifiedItem <IProjectItem>(qualifiedName);

            if (projectItem == null)
            {
                context.Trace.WriteLine(Texts.Project_item_not_found__ + qualifiedName);
                return;
            }

            foreach (var reference in projectItem.References)
            {
                string line = $"{reference.Owner.Snapshot.SourceFile.ProjectFileName}";

                var textNode = reference.TextNode;
                line += $"({textNode.TextSpan.LineNumber},{textNode.TextSpan.LineNumber})";

                line += ": " + reference.ReferenceText;

                if (!reference.IsValid)
                {
                    line += " (not valid)";
                }

                context.Trace.WriteLine(line);
            }

            context.Trace.WriteLine(Texts.Found__ + projectItem.References.Count);
        }
Ejemplo n.º 13
0
        public override void Run(IBuildContext context)
        {
            var project = context.LoadProject();

            context.Trace.TraceInformation(Msg.D1029, "Publishing project...");

            if (project.Diagnostics.Any(d => d.Severity == Severity.Error))
            {
                context.Trace.TraceError(Msg.E1048, "Project contains errors and will not be published");
                return;
            }

            var format = Format;

            if (string.IsNullOrEmpty(format))
            {
                format = "package";
            }

            var projectEmitters = ProjectEmitters.Where(p => p.CanEmit(format)).ToArray();

            if (!projectEmitters.Any())
            {
                context.Trace.TraceError(Msg.E1043, "No project emitters found");
                return;
            }

            foreach (var projectEmitter in projectEmitters)
            {
                var emitContext = Factory.EmitContext(projectEmitter, project);

                projectEmitter.Emit(emitContext, project);

                context.OutputFiles.AddRange(emitContext.OutputFiles);
            }
        }