public void CreateManifestAndZip()
        {
            const string version = "v4.5.0.0";
            const int release = 1;
            const string zipFileName = "AutoUploader_{0}_r{1}.zip";
            const string autoUploaderUpdateZipName ="Ticket Evolution Auto Uploader.zip";
            const string manifestName = "AutoUploaderManifest.xml";

            const string sourcePath = @"C:\Users\Mitchell Rosmarin\Documents\Visual Studio 2010\Projects\TicketEvolution\trunk\TicketEvolution.Setup\Release\";
            const string targetPath = @"C:\Users\Mitchell Rosmarin\Documents\Visual Studio 2010\Projects\TicketEvolution\trunk\TicketEvolution.Files\Updater\";

            var versionPath = Path.Combine(targetPath, version);
            var setupPath = Path.Combine(versionPath, "Setup");
            var updatePath = Path.Combine(versionPath, "Update");
            var tempPath = Path.Combine(Path.GetTempPath(), String.Format("AutoUploader_{0}", version));

            var msiFile = Path.Combine(setupPath, "TicketEvolution.Setup.msi");
            var zipFile = Path.Combine(setupPath, string.Format(zipFileName, version, release));
            var manifestFile = Path.Combine(updatePath, manifestName);
            var autoUploaderUpdateZipFile = Path.Combine(updatePath, autoUploaderUpdateZipName);

            CreateDirectories(new List<string> { versionPath, setupPath, tempPath, updatePath });
            CopyTopLevelFiles(sourcePath, setupPath);

            //need to create zip release
            CompressFiles(setupPath, zipFile);
            if (!File.Exists(zipFile))
                return;

            UnPackMSI(msiFile, versionPath, tempPath);

            var fileList = Directory.EnumerateFiles(versionPath,"*.*",SearchOption.TopDirectoryOnly).ToList();
            var excludeList = new List<string> { Path.Combine(versionPath, "TicketEvolution.ReleaseHelper.exe")
                                                ,Path.Combine(versionPath, "TicketEvolution.ReleaseHelper.exe.config")};
            foreach (var file in excludeList)
                fileList.Remove(file);

            using (TextWriter writer = new StreamWriter(manifestFile))
            {
                var serializer = new XmlSerializer(typeof(Manifest));
                var manifest = new Manifest { ZipFileLocation = autoUploaderUpdateZipName, Files = new List<ManifestFile>() };
                foreach (var file in fileList)
                {
                    var fileVersionInfo = FileVersionInfo.GetVersionInfo(file);
                    manifest.Files.Add(new ManifestFile { FileVersion = fileVersionInfo.FileVersion, Name = Path.GetFileName(file) });
                }

                serializer.Serialize(writer, manifest);
                writer.Close();
            }

            CompressFiles(fileList, autoUploaderUpdateZipFile);
        }
Example #2
0
        //public void DeleteIteminS3Test()
        //{
        //    AmazonS3Service.DeleteBucketItem(CreateS3ItemKey(ManifestFullFileName), BucketName);
        //    AmazonS3Service.DeleteBucketItem(CreateS3ItemKey(AutoUploaderUpdateZip), BucketName);
        //}
        public void CreateManifestAndZip()
        {
            var version = String.Format("v{0}.{1}.{2}.{3}", txtManifestVersion1.Text, txtManifestVersion2.Text,
                                        txtManifestVersion3.Text, txtManifestVersion4.Text);
            var release = int.Parse(txtRelease.Text);
            const string zipFileName = "AutoUploader_{0}_r{1}.zip";

            var autoUploaderUpdateZipName = txtUpdateZipName.Text;
            var manifestName = txtManifestName.Text;
            var sourcePath = txtReleaseFilesLocation.Text;
            var debugSourcePath = txtDebugLocation.Text;
            var targetPath = txtUpdateFilesLocation.Text;

            var versionPath = Path.Combine(targetPath, version);
            var setupPath = Path.Combine(versionPath, "Setup");
            var debugPath = Path.Combine(setupPath, "Debug");
            var updatePath = Path.Combine(versionPath, "Update");
            var tempPath = Path.Combine(Path.GetTempPath(), String.Format("AutoUploader_{0}", version));

            var msiFile = Path.Combine(setupPath, "TicketEvolution.Setup.msi");
            var zipFile = Path.Combine(setupPath, string.Format(zipFileName, version.Replace(".","_"), release));
            var manifestFile = Path.Combine(updatePath, manifestName);
            var autoUploaderUpdateZipFile = Path.Combine(updatePath, autoUploaderUpdateZipName);

            CreateDirectories(new List<string> { versionPath, setupPath, tempPath, updatePath,debugPath });
            CopyTopLevelFiles(sourcePath, setupPath);
            CopyTopLevelFiles(debugSourcePath, debugPath);

            //need to create zip release
            CompressFiles(setupPath, zipFile);
            if (!File.Exists(zipFile))
                return;

            UnPackMSI(msiFile, versionPath, tempPath);

            var fileList = Directory.EnumerateFiles(versionPath, "*.*", SearchOption.TopDirectoryOnly).ToList();
            var excludeList = new List<string> { Path.Combine(versionPath, "TicketEvolution.Setup.msi")
                                                ,Path.Combine(versionPath, "TicketEvolution.ReleaseHelper.exe")
                                                ,Path.Combine(versionPath, "TicketEvolution.ReleaseHelper.exe.config")};
            foreach (var file in excludeList)
                fileList.Remove(file);

            using (TextWriter writer = new StreamWriter(manifestFile))
            {
                var serializer = new XmlSerializer(typeof(Manifest));
                var manifest = new Manifest
                                   {
                                       ZipFileLocation = autoUploaderUpdateZipName,
                                       Files = new List<ManifestFile>(),
                                       AppVersion = version
                                   };
                foreach (var file in fileList)
                {
                    var fileVersionInfo = FileVersionInfo.GetVersionInfo(file);
                    manifest.Files.Add(new ManifestFile { FileVersion = fileVersionInfo.FileVersion, Name = Path.GetFileName(file) });
                }

                serializer.Serialize(writer, manifest);
                writer.Close();
            }

            CompressFiles(fileList, autoUploaderUpdateZipFile);

            if (chkUploadFiles.Checked)
            {
                AmazonS3Service.PutBucketItem(CreateS3ItemKey(manifestName), txtBucketName.Text, manifestFile);
                AmazonS3Service.PutBucketItem(CreateS3ItemKey(autoUploaderUpdateZipName), txtBucketName.Text,
                                              autoUploaderUpdateZipFile);
            }
        }