diff options
Diffstat (limited to 'Mono.Addins/Mono.Addins.Description/AddinDescription.cs')
-rw-r--r-- | Mono.Addins/Mono.Addins.Description/AddinDescription.cs | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/Mono.Addins/Mono.Addins.Description/AddinDescription.cs b/Mono.Addins/Mono.Addins.Description/AddinDescription.cs index 158dbec..4d3bf62 100644 --- a/Mono.Addins/Mono.Addins.Description/AddinDescription.cs +++ b/Mono.Addins/Mono.Addins.Description/AddinDescription.cs @@ -892,6 +892,103 @@ namespace Mono.Addins.Description } } } + + public XmlDocument SaveToVsixXml () + { + if (!canWrite) + throw new InvalidOperationException ("Can't write incomplete description."); + + XmlElement packageManifestEl; + + var vsixDoc = new XmlDocument (); + vsixDoc.AppendChild (vsixDoc.CreateElement ("PackageManifest")); + + packageManifestEl = vsixDoc.DocumentElement; + packageManifestEl.SetAttribute ("Version", "2.0.0"); + packageManifestEl.SetAttribute ("xmlns", "http://schemas.microsoft.com/developer/vsx-schema/2011"); + + var metadata = vsixDoc.CreateElement ("Metadata"); + var identity = vsixDoc.CreateElement ("Identity"); + identity.SetAttribute ("Language", "en-US"); + identity.SetAttribute ("Id", LocalId); + identity.SetAttribute ("Version", Version); + identity.SetAttribute ("Publisher", Properties.GetPropertyValue ("VisualStudio.Publisher")); + metadata.AppendChild (identity); + + var displayNameEl = vsixDoc.CreateElement ("DisplayName"); + displayNameEl.InnerText = Name; + metadata.AppendChild (displayNameEl); + + var descriptionEl = vsixDoc.CreateElement ("Description"); + descriptionEl.SetAttribute ("xml:space", "preserve"); + descriptionEl.InnerText = Description; + metadata.AppendChild (descriptionEl); + + var moreInfoEl = vsixDoc.CreateElement ("MoreInfo"); + moreInfoEl.InnerText = Url; + metadata.AppendChild (moreInfoEl); + + var tagsEl = vsixDoc.CreateElement ("Tags"); + if (!string.IsNullOrEmpty (Properties.GetPropertyValue ("VisualStudio.Tags"))) + tagsEl.InnerText = Properties.GetPropertyValue ("VisualStudio.Tags"); + metadata.AppendChild (tagsEl); + + var categoriesEl = vsixDoc.CreateElement ("Categories"); + categoriesEl.InnerText = Category; + metadata.AppendChild (categoriesEl); + + var galleryFlagsEl = vsixDoc.CreateElement ("GalleryFlags"); + var galleryFlags = Properties.GetPropertyValue ("VisualStudio.GalleryFlags"); + if (string.IsNullOrEmpty (galleryFlags)) + galleryFlags = "Public"; + galleryFlagsEl.InnerText = galleryFlags; + metadata.AppendChild (galleryFlagsEl); + + var badgesEl = vsixDoc.CreateElement ("Badges"); + //TODO:Add Badges support + metadata.AppendChild (badgesEl); + + var icon = Properties.GetPropertyValue ("Icon32"); + if (!string.IsNullOrEmpty (icon)) { + var iconEl = vsixDoc.CreateElement ("Icon"); + iconEl.InnerText = icon; + metadata.AppendChild (iconEl); + } + var license = Copyright; + if (!string.IsNullOrEmpty (license)) { + var licenseEl = vsixDoc.CreateElement ("License"); + licenseEl.InnerText = license; + metadata.AppendChild (licenseEl); + } + + packageManifestEl.AppendChild (metadata); + + var installationEl = vsixDoc.CreateElement ("Installation"); + var installationTargetEl = vsixDoc.CreateElement ("InstallationTarget"); + installationTargetEl.SetAttribute ("Id", "Microsoft.VisualStudio.Mac"); + installationEl.AppendChild (installationTargetEl); + packageManifestEl.AppendChild (installationEl); + + packageManifestEl.AppendChild (vsixDoc.CreateElement ("Dependencies")); + + var assetsEl = vsixDoc.CreateElement ("Assets"); + var addinInfoAsset = vsixDoc.CreateElement ("Asset"); + addinInfoAsset.SetAttribute ("Type", "Microsoft.VisualStudio.Mac.AddinInfo"); + addinInfoAsset.SetAttribute ("Path", "addin.info"); + addinInfoAsset.SetAttribute ("Addressable", "true"); + assetsEl.AppendChild (addinInfoAsset); + + if (!string.IsNullOrEmpty (icon)) { + var iconAsset = vsixDoc.CreateElement ("Asset"); + iconAsset.SetAttribute ("Type", "Microsoft.VisualStudio.Services.Icons.Default"); + iconAsset.SetAttribute ("Path", icon); + iconAsset.SetAttribute ("Addressable", "true"); + assetsEl.AppendChild (iconAsset); + } + packageManifestEl.AppendChild (assetsEl); + + return vsixDoc; + } void SaveCoreProperty (XmlElement elem, string val, string attr, string prop) { |