예제 #1
0
        public override bool Execute()
        {
            try
            {
                // Initialise everything.

                Initialise();

                Tasks.Catalogue catalogue = new Tasks.Catalogue();

                using (Assembler assembler = new Assembler(Options, Log))
                {
                    // Assemble all artifacts.

                    AssembleArtifacts(catalogue, assembler, CreateArtifacts(), Action.Assemble);
                }

                // Save the catalogue file.

                catalogue.Save(Options.OutputFolder, Options.CatalogueFile, Options.CatalogueFileGuid);

                // Finalise everything.

                Finalise();
                return(true);
            }
            catch (System.Exception e)
            {
                Log.LogErrorFromException(e);
                return(false);
            }
        }
예제 #2
0
        public override void Clean(Action action)
        {
            // Load the catalogue.

            Tasks.Catalogue catalogue = LoadCatalogue();

            // Determine the root folder for the artifacts within the catalogue.

            if (catalogue.RootFolder != string.Empty)
            {
                string rootFolder = FilePath.GetAbsolutePath(catalogue.RootFolder, Path.GetDirectoryName(SourceFullPath));

                using (Assembler assembler = new Assembler(Options, Log))
                {
                    // Iterate over each artifact.

                    foreach (Artifact artifact in catalogue.Artifacts)
                    {
                        // Assemble the file from where it was assembled as part of the catalogue.

                        string artifactSourceFullPath      = FilePath.GetAbsolutePath(artifact.ProjectRelativePath, rootFolder);
                        string artifactDestinationFullPath = FilePath.GetAbsolutePath(artifact.ProjectRelativePath, Options.OutputFolder);

                        assembler.DeleteArtifact(artifact, action, artifactSourceFullPath, artifactDestinationFullPath);
                    }
                }
            }

            // Delete the file itself.

            Delete(DestinationFullPath);
        }
예제 #3
0
 private Tasks.Catalogue LoadCatalogue()
 {
     Tasks.Catalogue catalogue = new Tasks.Catalogue();
     if (System.IO.File.Exists(SourceFullPath))
     {
         catalogue.Load(SourceFullPath);
     }
     return(catalogue);
 }
예제 #4
0
        public override void Assemble(Action action)
        {
            // Copy the source itself.

            Copy(SourceFullPath);

            // Load the catalogue.

            Tasks.Catalogue catalogue = LoadCatalogue();

            if (catalogue.Artifacts.Count > 0)
            {
                // Determine the root folder for the artifacts within the catalogue.

                string rootFolder = FilePath.GetAbsolutePath(catalogue.RootFolder, Path.GetDirectoryName(SourceFullPath));

                using (Assembler assembler = new Assembler(Options, Log))
                {
                    // Iterate over each artifact.

                    foreach (Artifact artifact in catalogue.Artifacts)
                    {
                        // Assemble the file from where it was assembled as part of the catalogue.

                        string artifactSourceFullPath      = FilePath.GetAbsolutePath(artifact.ProjectRelativePath, rootFolder);
                        string artifactDestinationFullPath = FilePath.GetAbsolutePath(artifact.ProjectRelativePath, Options.OutputFolder);

                        // For artifacts in catalogues do not do the full assemble, just copy.

                        assembler.CopyArtifact(artifact, action, artifactSourceFullPath, artifactDestinationFullPath);

                        // Copy associated artifacts as well.

                        foreach (Artifact associatedArtifact in artifact.AssociatedArtifacts)
                        {
                            artifactSourceFullPath      = FilePath.GetAbsolutePath(associatedArtifact.ProjectRelativePath, rootFolder);
                            artifactDestinationFullPath = FilePath.GetAbsolutePath(associatedArtifact.ProjectRelativePath, Options.OutputFolder);
                            assembler.CopyArtifact(associatedArtifact, action, artifactSourceFullPath, artifactDestinationFullPath);
                        }
                    }
                }
            }
        }
예제 #5
0
        private void AssembleArtifacts(Tasks.Catalogue catalogue, Assembler assembler, IEnumerable <KeyValuePair <string, Artifact> > artifacts, Action action)
        {
            // Iterate over each artifact.

            foreach (KeyValuePair <string, Artifact> pair in artifacts)
            {
                string   sourcePath = pair.Key;
                Artifact artifact   = pair.Value;

                // Determine the paths for the artifact.

                string sourceFullPath      = GetSourceFullPath(sourcePath);
                string destinationFullPath = GetDestinationFullPath(artifact);

                // Assemble it.

                assembler.AssembleArtifact(artifact, action, sourceFullPath, destinationFullPath);
                catalogue.Add(artifact);
            }
        }