41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
using Packager.Parameters;
|
|
|
|
namespace Packager.Tasks
|
|
{
|
|
[DisplayName("Extract Common Files")]
|
|
public class ExtractCommon: Task
|
|
{
|
|
[Input("File Lists", IOCardinality.Multi, IOType.File)]
|
|
public List<string> FileLists { get; set; }
|
|
|
|
[Output("Common Files List", IOType.File)]
|
|
public List<string> CommonFilesList = new List<string>();
|
|
|
|
public ExtractCommon()
|
|
{
|
|
FileLists = new List<string>();
|
|
}
|
|
|
|
protected override void StartInternal(BuildConfiguration profile, cookerWrapper cooker, TaskIO inputs, string outputFolder)
|
|
{
|
|
IEnumerable<string> commonList = null;
|
|
foreach (var file in inputs["FileLists"])
|
|
{
|
|
var list = File.ReadAllLines(file);
|
|
|
|
commonList = commonList?.Intersect(list) ?? list;
|
|
}
|
|
|
|
var commonName = Path.Combine(outputFolder, "common.txt");
|
|
if (commonList != null) File.WriteAllLines(commonName, commonList);
|
|
CommonFilesList.Add(commonName);
|
|
|
|
//OnFinished(0);
|
|
}
|
|
}
|
|
}
|