Created
April 28, 2013 23:05
-
-
Save jrusbatch/5478788 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<UsingTask TaskName="CombinePackageConfigs" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> | |
<ParameterGroup> | |
<PackageConfigFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" /> | |
<OutputPath ParameterType="System.String" Required="true" /> | |
<CreatedFile ParameterType="Microsoft.Build.Framework.ITaskItem" Output="true" /> | |
</ParameterGroup> | |
<Task> | |
<Reference Include="System.Xml" /> | |
<Reference Include="System.Xml.Linq" /> | |
<Using Namespace="System.IO" /> | |
<Using Namespace="System.Linq" /> | |
<Using Namespace="System.Xml" /> | |
<Using Namespace="System.Xml.Linq" /> | |
<Code Type="Fragment" Language="cs"> | |
<![CDATA[ | |
var packages = | |
PackageConfigFiles.AsParallel() | |
.Select(x => XDocument.Load(x.GetMetadata("FullPath"))) | |
.SelectMany(x => x.Root.Elements("package")) | |
.Select(x => new { Id = (string)x.Attribute("id"), Version = (string)x.Attribute("version") }) | |
.Distinct(); | |
var document = | |
new XDocument( | |
new XElement("packages", | |
packages.Select(x => new XElement("package", new XAttribute("id", x.Id), new XAttribute("version", x.Version))))); | |
document.Save(OutputPath); | |
]]> | |
</Code> | |
</Task> | |
</UsingTask> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment