Exemplo n.º 1
0
        internal void ExportManifest(string fullpath, bool askForConfirmation = true, bool includeFilesSection = true)
        {
            if (File.Exists(fullpath) && askForConfirmation)
            {
                bool confirmed = UIServices.Confirm(
                    Resources.ConfirmToReplaceFile_Title,
                    String.Format(CultureInfo.CurrentCulture, Resources.ConfirmToReplaceFile, fullpath));
                if (!confirmed)
                {
                    return;
                }
            }

            string rootPath = Path.GetDirectoryName(fullpath);

            using (Stream fileStream = File.Create(fullpath))
            {
                Manifest manifest = Manifest.Create(PackageMetadata);
                if (includeFilesSection)
                {
                    string tempPath = Path.GetTempPath();

                    manifest.Files.AddRange(RootFolder.GetFiles().Select(
                                                f => new ManifestFile
                    {
                        Source = String.IsNullOrEmpty(f.OriginalPath()) || f.OriginalPath().StartsWith(tempPath, StringComparison.OrdinalIgnoreCase) ? f.Path : PathUtility.RelativePathTo(rootPath, f.OriginalPath()),
                        Target = f.Path
                    })
                                            );
                }
                manifest.Save(fileStream);
            }
        }