public Package CreateFromManifest(string tempFolder, string repo, string issuetracker)
        {
            string xml = File.ReadAllText(Path.Combine(tempFolder, "extension.vsixmanifest"));
            xml = Regex.Replace(xml, "( xmlns(:\\w+)?)=\"([^\"]+)\"", string.Empty);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            Package package = new Package();

            if (doc.GetElementsByTagName("DisplayName").Count > 0)
            {
                Vs2012Format(repo, issuetracker, doc, package);
            }
            else
            {
                Vs2010Format(repo, issuetracker, doc, package);
            }

            string license = ParseNode(doc, "License", false);
            if (!string.IsNullOrEmpty(license))
            {
                string path = Path.Combine(tempFolder, license);
                if (File.Exists(path))
                {
                    package.License = File.ReadAllText(path);
                }
            }

            return package;
        }
        private void AddEntry(XmlWriter writer, Package package, string baseUrl)
        {
            writer.WriteStartElement("entry");

            writer.WriteElementString("id", package.ID);

            writer.WriteStartElement("title");
            writer.WriteAttributeString("type", "text");
            writer.WriteValue(package.Name);
            writer.WriteEndElement(); // title

            writer.WriteStartElement("link");
            writer.WriteAttributeString("rel", "alternate");
            writer.WriteAttributeString("href", baseUrl + "/extensions/" + package.ID + "/extension.vsix");
            writer.WriteEndElement(); // link

            writer.WriteStartElement("summary");
            writer.WriteAttributeString("type", "text");
            writer.WriteValue(package.Description);
            writer.WriteEndElement(); // summary

            writer.WriteElementString("published", package.DatePublished.ToString("yyyy-MM-ddTHH:mm:ssZ"));
            writer.WriteElementString("updated", package.DatePublished.ToString("yyyy-MM-ddTHH:mm:ssZ"));

            writer.WriteStartElement("author");
            writer.WriteElementString("name", package.Author);
            writer.WriteEndElement(); // author

            writer.WriteStartElement("content");
            writer.WriteAttributeString("type", "application/octet-stream");
            writer.WriteAttributeString("src", baseUrl + "/extensions/" + package.ID + "/extension.vsix");
            writer.WriteEndElement(); // content

            writer.WriteStartElement("link");
            writer.WriteAttributeString("rel", "icon");
            writer.WriteAttributeString("href", baseUrl + "/extensions/" + package.ID + "/" + package.Icon);
            writer.WriteEndElement(); // icon

            writer.WriteStartElement("link");
            writer.WriteAttributeString("rel", "previewimage");
            writer.WriteAttributeString("href", baseUrl + "/extensions/" + package.ID + "/" + package.Preview);
            writer.WriteEndElement(); // preview

            writer.WriteRaw("\r\n<Vsix xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://schemas.microsoft.com/developer/vsx-syndication-schema/2010\">\r\n");

            writer.WriteElementString("Id", package.ID);
            writer.WriteElementString("Version", package.Version);

            writer.WriteStartElement("References");
            writer.WriteEndElement();

            writer.WriteRaw("</Vsix>");// Vsix
            writer.WriteEndElement(); // entry
        }
		private void SavePackage(string tempFolder, Package package, string vsixFolder)
		{
			if (Directory.Exists(vsixFolder))
				Directory.Delete(vsixFolder, true);

			Directory.CreateDirectory(vsixFolder);

			string icon = Path.Combine(tempFolder, package.Icon ?? string.Empty);
			if (File.Exists(icon))
			{
				File.Copy(icon, Path.Combine(vsixFolder, "icon-" + package.Version + ".png"), true);
				package.Icon = "icon-" + package.Version + ".png";
            }

			string preview = Path.Combine(tempFolder, package.Preview ?? string.Empty);
			if (File.Exists(preview))
			{
				File.Copy(preview, Path.Combine(vsixFolder, "preview-" + package.Version + ".png"), true);
				package.Preview = "preview-" + package.Version + ".png";
			}

			string json = JsonConvert.SerializeObject(package);

			File.WriteAllText(Path.Combine(vsixFolder, "extension.json"), json, Encoding.UTF8);

			Package existing = PackageCache.FirstOrDefault(p => p.ID == package.ID);

			if (PackageCache.Contains(existing))
			{
				PackageCache.Remove(existing);
			}

			PackageCache.Add(package);
		}
 private void Vs2010Format(string repo, string issuetracker, XmlDocument doc, Package package)
 {
     package.ID = ParseNode(doc, "Identifier", true, "Id");
     package.Name = ParseNode(doc, "Name", true);
     package.Description = ParseNode(doc, "Description", true);
     package.Version = new Version(ParseNode(doc, "Version", true)).ToString();
     package.Author = ParseNode(doc, "Author", true);
     package.Icon = ParseNode(doc, "Icon", false);
     package.Preview = ParseNode(doc, "PreviewImage", false);
     package.DatePublished = DateTime.UtcNow;
     package.SupportedVersions = GetSupportedVersions(doc);
     package.ReleaseNotesUrl = ParseNode(doc, "ReleaseNotes", false);
     package.GettingStartedUrl = ParseNode(doc, "GettingStartedGuide", false);
     package.MoreInfoUrl = ParseNode(doc, "MoreInfo", false);
     package.Repo = repo;
     package.IssueTracker = issuetracker;
 }