static void Vs2010Format(XmlDocument doc, Manifest manifest) { manifest.Author = ParseNode(doc, "Author", true); manifest.Description = ParseNode(doc, "Description", true); manifest.GettingStartedUrl = ParseNode(doc, "GettingStartedGuide", false); manifest.Icon = ParseNode(doc, "Icon", false); manifest.ID = ParseNode(doc, "Identifier", true, "Id"); manifest.License = ParseNode(doc, "License", false); manifest.MoreInfoUrl = ParseNode(doc, "MoreInfo", false); manifest.Name = ParseNode(doc, "Name", true); manifest.Preview = ParseNode(doc, "PreviewImage", false); manifest.ReleaseNotesUrl = ParseNode(doc, "ReleaseNotes", false); manifest.Version = new Version(ParseNode(doc, "Version", true)).ToString(); }
protected override byte[] GenerateCode(string inputFileName, string inputFileContent) { _manifest = VsixManifestParser.FromManifest(inputFileContent); var item = Dte.Solution.FindProjectItem(inputFileName); if (item != null) { GenerateIconFile(item); GenerateClassFile(item); SetBuildProperties(inputFileName, item); } return GenerateResource(); }
public static Manifest FromManifest(string vsixManifestContent) { var xml = Regex.Replace(vsixManifestContent, "( xmlns(:\\w+)?)=\"([^\"]+)\"", string.Empty) .Replace(" d:", " "); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); var package = new Manifest(); if (doc.GetElementsByTagName("DisplayName").Count > 0) { Vs2012Format(doc, package); } else { Vs2010Format(doc, package); } return package; }
public static async System.Threading.Tasks.Task<string> ReplaceTokens(string file, Manifest manifest) { using (var reader = new StreamReader(file)) { var content = await reader.ReadToEndAsync(); if (manifest != null) { var properties = typeof(Manifest).GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (var property in properties) { var value = property.GetValue(manifest); if (value != null) content = content.Replace("{" + property.Name + "}", value.ToString()); } } return content; } }