diff options
author | David Karlaš <david.karlas@microsoft.com> | 2017-11-24 12:53:45 +0300 |
---|---|---|
committer | David Karlaš <david.karlas@microsoft.com> | 2018-02-21 17:17:19 +0300 |
commit | 0fbfe8c5c4b9aba750f3919d3a6b8dba3a612930 (patch) | |
tree | c6f0c568ecdf32548a24c578827f556c262f5c25 /Mono.Addins | |
parent | 136a3322119e147fa69d9a5a74a7a64da2199ce5 (diff) |
Initial .vsix support
Diffstat (limited to 'Mono.Addins')
-rw-r--r-- | Mono.Addins/Mono.Addins.Description/AddinDescription.cs | 97 | ||||
-rw-r--r-- | Mono.Addins/Mono.Addins.Description/PackageFormat.cs | 32 | ||||
-rw-r--r-- | Mono.Addins/Mono.Addins.csproj | 1 |
3 files changed, 130 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) { diff --git a/Mono.Addins/Mono.Addins.Description/PackageFormat.cs b/Mono.Addins/Mono.Addins.Description/PackageFormat.cs new file mode 100644 index 0000000..8a22673 --- /dev/null +++ b/Mono.Addins/Mono.Addins.Description/PackageFormat.cs @@ -0,0 +1,32 @@ +// +// PackageFormat.cs +// +// Author: +// David Karlaš +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +namespace Mono.Addins.Description +{ + public enum PackageFormat + { + Mpack, + Vsix + } +} diff --git a/Mono.Addins/Mono.Addins.csproj b/Mono.Addins/Mono.Addins.csproj index a4522af..e7a1d01 100644 --- a/Mono.Addins/Mono.Addins.csproj +++ b/Mono.Addins/Mono.Addins.csproj @@ -155,6 +155,7 @@ <Compile Include="Mono.Addins\AddinCategoryAttribute.cs" /> <Compile Include="Mono.Addins\AddinFlagsAttribute.cs" /> <Compile Include="Mono.Addins\AddinLocalizerAttribute.cs" /> + <Compile Include="Mono.Addins.Description\PackageFormat.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> </Project> |