Example #1
0
        private void CreateNugetPackage(RelaseRequest request)
        {
            var metadata = new ManifestMetadata()
            {
                Id          = request.AppId,
                Authors     = request.Authors,
                Version     = request.Version,
                Description = request.Title,
                Title       = request.Title,
            };

            if (File.Exists(request.AppIcon))
            {
                metadata.IconUrl = _distributor.DistributeFile(request.AppIcon);
            }

            PackageBuilder builder = new PackageBuilder();

            builder.Populate(metadata);

            //As Squirrel convention i put everything in lib/net45 folder
            List <ManifestFile> files = new List <ManifestFile>();

            AddDirectoryFilesToPath(request.SourceDir, files, true);

            builder.PopulateFiles("", files.ToArray());

            if (Directory.Exists(Path.GetDirectoryName(request.NugetPackagePath)) == false)
            {
                Directory.CreateDirectory(Path.GetDirectoryName(request.NugetPackagePath));
            }

            if (File.Exists(request.NugetPackagePath))
            {
                File.Delete(request.NugetPackagePath);
            }

            using (FileStream stream = File.Open(request.NugetPackagePath, FileMode.OpenOrCreate))
            {
                builder.Save(stream);
            }

            $"Nuget package {request.AppId}.{request.Version}.nupkg created".WriteSuccessToConsole();
        }