コード例 #1
0
        public FileInfo CreatePluginPackage(PluginDescriptor descriptor)
        {
            var result = new PackagingResult
            {
                ExtensionType  = "Plugin",
                PackageName    = descriptor.FolderName,
                PackageVersion = descriptor.Version.ToString(),
                PackageStream  = _packageBuilder.BuildPackage(descriptor)
            };

            return(SavePackageFile(result));
        }
コード例 #2
0
        public PackagingResult BuildPluginPackage(string pluginName)
        {
            var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName(pluginName);

            if (pluginDescriptor == null)
            {
                return(null);
            }
            return(new PackagingResult
            {
                ExtensionType = "Plugin",
                PackageName = pluginDescriptor.FolderName,
                PackageVersion = pluginDescriptor.Version.ToString(),
                PackageStream = _packageBuilder.BuildPackage(pluginDescriptor)
            });
        }
コード例 #3
0
ファイル: PackageManager.cs プロジェクト: vard0/orchard.tan
        public PackageData Harvest(string extensionName)
        {
            ExtensionDescriptor extensionDescriptor = _extensionManager.AvailableExtensions().FirstOrDefault(x => x.Id == extensionName);

            if (extensionDescriptor == null)
            {
                return(null);
            }
            return(new PackageData {
                ExtensionType = extensionDescriptor.ExtensionType,
                ExtensionName = extensionDescriptor.Id,
                ExtensionVersion = extensionDescriptor.Version,
                PackageStream = _packageBuilder.BuildPackage(extensionDescriptor),
            });
        }
コード例 #4
0
        private Stream BuildHelloWorld(IPackageBuilder packageBuilder) {

            // add some content because NuGet requires it
            var folder = _container.Resolve<InMemoryWebSiteFolder>();
            using ( var sourceStream = GetType().Assembly.GetManifestResourceStream(GetType(), "Hello.World.csproj.txt") ) {
                folder.AddFile("~/Modules/Hello.World/Hello.World.csproj", new StreamReader(sourceStream).ReadToEnd());
            }
            
            return packageBuilder.BuildPackage(new ExtensionDescriptor {
                ExtensionType = DefaultExtensionTypes.Module,
                Id = PackageIdentifier,
                Version = "1.0",
                Description = "a",
                Author = "b"
            });
        }
コード例 #5
0
        private Stream BuildHelloWorld(IPackageBuilder packageBuilder)
        {
            // add some content because NuGet requires it
            var folder = _container.Resolve <InMemoryWebSiteFolder>();

            using (var sourceStream = GetType().Assembly.GetManifestResourceStream(GetType(), "Hello.World.csproj.txt")) {
                folder.AddFile("~/Modules/Hello.World/Hello.World.csproj", new StreamReader(sourceStream).ReadToEnd());
            }

            return(packageBuilder.BuildPackage(new ExtensionDescriptor {
                ExtensionType = DefaultExtensionTypes.Module,
                Id = PackageIdentifier,
                Version = "1.0",
                Description = "a",
                Author = "b"
            }));
        }
コード例 #6
0
        public Task Execute(string[] commandLineArguments)
        {
            return(Task.Run(() =>
            {
                optionGroups.Parse(commandLineArguments);

                if (string.IsNullOrWhiteSpace(id))
                {
                    throw new CommandException("An ID is required");
                }

                if (includes.All(string.IsNullOrWhiteSpace))
                {
                    includes.Add("**");
                }

                if (string.IsNullOrWhiteSpace(basePath))
                {
                    basePath = Path.GetFullPath(Directory.GetCurrentDirectory());
                }

                if (string.IsNullOrWhiteSpace(outFolder))
                {
                    outFolder = Path.GetFullPath(Directory.GetCurrentDirectory());
                }

                if (version == null)
                {
                    var now = DateTime.Now;
                    version = SemanticVersion.Parse($"{now.Year}.{now.Month}.{now.Day}.{now.Hour*10000 + now.Minute*100 + now.Second}");
                }

                if (authors.All(string.IsNullOrWhiteSpace))
                {
                    authors.Add(Environment.GetEnvironmentVariable("USERNAME") + "@" + Environment.GetEnvironmentVariable("USERDOMAIN"));
                }

                if (string.IsNullOrWhiteSpace(description))
                {
                    description = "A deployment package created from files on disk.";
                }

                string allReleaseNotes = null;
                if (!string.IsNullOrWhiteSpace(releaseNotesFile))
                {
                    if (!File.Exists(releaseNotesFile))
                    {
                        log.Warning("The release notes file '{Path:l}' could not be found", releaseNotesFile);
                    }
                    else
                    {
                        allReleaseNotes = fileSystem.ReadFile(releaseNotesFile);
                    }
                }

                if (!string.IsNullOrWhiteSpace(releaseNotes))
                {
                    if (allReleaseNotes != null)
                    {
                        allReleaseNotes += Environment.NewLine + releaseNotes;
                    }
                    else
                    {
                        allReleaseNotes = releaseNotes;
                    }
                }

                if (string.IsNullOrWhiteSpace(version.OriginalString))
                {
                    throw new Exception("Somehow we created a SemanticVersion without the OriginalString value being preserved. We want to use the OriginalString so we can preserve the version as intended by the caller.");
                }

                var metadata = new ManifestMetadata
                {
                    Id = id,
                    Authors = authors,
                    Description = description,
                    Version = NuGetVersion.Parse(version.OriginalString)
                };

                if (!string.IsNullOrWhiteSpace(allReleaseNotes))
                {
                    metadata.ReleaseNotes = allReleaseNotes;
                }

                if (!string.IsNullOrWhiteSpace(title))
                {
                    metadata.Title = title;
                }


                if (verbose)
                {
                    log.Information("Verbose logging");
                }
                log.Information("Packing {id:l} version {Version}...", id, version);

                packageBuilder.BuildPackage(basePath, includes, metadata, outFolder, overwrite, verbose);

                log.Information("Done.");
            }));
        }
コード例 #7
0
ファイル: PackCommand.cs プロジェクト: tylertgt/Octo.exe
        public void Execute(string[] commandLineArguments)
        {
            optionGroups.Parse(commandLineArguments);

            if (string.IsNullOrWhiteSpace(id))
            {
                throw new CommandException("An ID is required");
            }

            if (includes.All(string.IsNullOrWhiteSpace))
            {
                includes.Add("**");
            }

            if (string.IsNullOrWhiteSpace(basePath))
            {
                basePath = Path.GetFullPath(Environment.CurrentDirectory);
            }

            if (string.IsNullOrWhiteSpace(outFolder))
            {
                outFolder = Path.GetFullPath(Environment.CurrentDirectory);
            }

            if (version == null)
            {
                var now = DateTime.Now;
                version = new SemanticVersion(now.Year, now.Month, now.Day, now.Hour * 10000 + now.Minute * 100 + now.Second);
            }
            else
            {
                // Make sure SpecialVersion has 20 characters maximum (Limit imposed by NuGet)
                // https://nuget.codeplex.com/workitem/3426

                const int nugetSpecialVersionMaxLength = 20;
                if (!string.IsNullOrWhiteSpace(version.SpecialVersion) && version.SpecialVersion.Length > nugetSpecialVersionMaxLength)
                {
                    log.WarnFormat("SpecialVersion '{0}' will be truncated to {1} characters (NuGet limit)",
                                   version.SpecialVersion, nugetSpecialVersionMaxLength);

                    var specialVersion = version.SpecialVersion;
                    specialVersion = specialVersion.Substring(0, Math.Min(nugetSpecialVersionMaxLength, specialVersion.Length));

                    version = new SemanticVersion(version.Version, specialVersion);
                }
            }

            if (authors.All(string.IsNullOrWhiteSpace))
            {
                authors.Add(Environment.UserName + "@" + Environment.UserDomainName);
            }

            if (string.IsNullOrWhiteSpace(description))
            {
                description = "A deployment package created from files on disk.";
            }

            string allReleaseNotes = null;

            if (!string.IsNullOrWhiteSpace(releaseNotesFile))
            {
                if (!File.Exists(releaseNotesFile))
                {
                    log.WarnFormat("The release notes file '{0}' could not be found", releaseNotesFile);
                }
                else
                {
                    allReleaseNotes = fileSystem.ReadFile(releaseNotesFile);
                }
            }

            if (!string.IsNullOrWhiteSpace(releaseNotes))
            {
                if (allReleaseNotes != null)
                {
                    allReleaseNotes += Environment.NewLine + releaseNotes;
                }
                else
                {
                    allReleaseNotes = releaseNotes;
                }
            }

            var metadata = new ManifestMetadata
            {
                Id          = id,
                Authors     = string.Join(", ", authors),
                Description = description,
                Version     = version.ToString(),
            };

            if (!string.IsNullOrWhiteSpace(allReleaseNotes))
            {
                metadata.ReleaseNotes = allReleaseNotes;
            }

            if (!string.IsNullOrWhiteSpace(title))
            {
                metadata.Title = title;
            }

            log.InfoFormat("Packing {0} version {1}...", id, version);

            packageBuilder.BuildPackage(basePath, includes, metadata, outFolder, overwrite);

            log.InfoFormat("Done.");
        }
コード例 #8
0
ファイル: PackCommand.cs プロジェクト: ShaKann/OctopusClients
        public void Execute(string[] commandLineArguments)
        {
            optionGroups.Parse(commandLineArguments);

            if (string.IsNullOrWhiteSpace(id))
            {
                throw new CommandException("An ID is required");
            }

            if (includes.All(string.IsNullOrWhiteSpace))
            {
                includes.Add("**");
            }

            if (string.IsNullOrWhiteSpace(basePath))
            {
                basePath = Path.GetFullPath(Environment.CurrentDirectory);
            }

            if (string.IsNullOrWhiteSpace(outFolder))
            {
                outFolder = Path.GetFullPath(Environment.CurrentDirectory);
            }

            if (version == null)
            {
                var now = DateTime.Now;
                version = new SemanticVersion(now.Year, now.Month, now.Day, now.Hour * 10000 + now.Minute * 100 + now.Second);
            }

            if (authors.All(string.IsNullOrWhiteSpace))
            {
                authors.Add(Environment.UserName + "@" + Environment.UserDomainName);
            }

            if (string.IsNullOrWhiteSpace(description))
            {
                description = "A deployment package created from files on disk.";
            }

            string allReleaseNotes = null;

            if (!string.IsNullOrWhiteSpace(releaseNotesFile))
            {
                if (!File.Exists(releaseNotesFile))
                {
                    log.Warning("The release notes file '{0}' could not be found", releaseNotesFile);
                }
                else
                {
                    allReleaseNotes = fileSystem.ReadFile(releaseNotesFile);
                }
            }

            if (!string.IsNullOrWhiteSpace(releaseNotes))
            {
                if (allReleaseNotes != null)
                {
                    allReleaseNotes += Environment.NewLine + releaseNotes;
                }
                else
                {
                    allReleaseNotes = releaseNotes;
                }
            }

            var metadata = new ManifestMetadata
            {
                Id          = id,
                Authors     = authors,
                Description = description,
                Version     = version.ToNuGetVersion(),
            };

            if (!string.IsNullOrWhiteSpace(allReleaseNotes))
            {
                metadata.ReleaseNotes = allReleaseNotes;
            }

            if (!string.IsNullOrWhiteSpace(title))
            {
                metadata.Title = title;
            }

            log.Information("Packing {0} version {1}...", id, version);

            packageBuilder.BuildPackage(basePath, includes, metadata, outFolder, overwrite);

            log.Information("Done.");
        }