bool generateSpecfile(string fname, FileVersionInfo fvi, string inPath, out ITaskItem pkg1, out List <ITaskItem> content) { bool ret = true; string versionValue, idValue, authorsValue, descValue, copyrightValue, ownerValue, pkgValue; pkg1 = null; content = new List <ITaskItem>(); versionValue = fvi.ProductVersion; versionValue = new Version(fvi.ProductMajorPart, fvi.ProductMinorPart, fvi.ProductBuildPart).ToString(); idValue = fvi.ProductName; idValue = Path.GetFileNameWithoutExtension(inPath); copyrightValue = fvi.LegalCopyright; authorsValue = "blah"; descValue = fvi.Comments; ownerValue = fvi.CompanyName; pkgValue = Path.Combine(inPath, idValue + versionValue + ".nupkg"); pkgValue = Path.Combine( Path.GetDirectoryName(fname), idValue + "." + versionValue + ".nupkg"); pkg = null; //Microsoft.Build. //var logctx=((ITask) this).BuildEngine. #if USE_TEST_TASK_ITEM pkg1 = new TestTaskItem(pkgValue); #else pkg1 = new TaskItem(pkgValue); #endif content.AddRange(new ITaskItem[] { makeTaskItem("id", idValue), makeTaskItem("version", versionValue), makeTaskItem("authors", authorsValue), makeTaskItem("owners", ownerValue), makeTaskItem("description", descValue),// makeTaskItem("copyright", copyrightValue), }); ITaskItem iti = makeItem("NuspecFile", inPath); try { using (XmlWriter xw = XmlWriter.Create(fname, settings)) { xw.WriteStartDocument(); xw.WriteStartElement("package"); xw.WriteStartElement("metadata"); xw.WriteElementString("id", idValue); xw.WriteElementString("version", versionValue); xw.WriteElementString("authors", authorsValue); xw.WriteElementString("owners", fvi.CompanyName); xw.WriteElementString("description", descValue); xw.WriteElementString("copyright", copyrightValue); addDependencies(xw, this._depends.ToArray()); xw.WriteEndElement(); addFiles(xw, new ITaskItem[] { iti }); xw.WriteEndDocument(); } } catch (Exception ex) { ret = false; } return(ret); }
void populateData(string elementName, List <ITaskItem> content) { ITaskItem ti; string key; #if USE_TEST_TASK_ITEM ti = new TestTaskItem(elementName); #else ti = new TaskItem(elementName); #endif foreach (ITaskItem iti in content) { key = iti.ItemSpec; ti.SetMetadata(key, iti.GetMetadata(key)); } _data.Clear(); _data.Add(ti); }