JD2022-TU1/main/tools/apps/Packager/Tasks/GenerateUpdateDependencies.cs

41 lines
No EOL
1.4 KiB
C#

using System.ComponentModel;
using System.IO;
using JD.Core.ProjectManaging;
using Packager.Parameters;
namespace Packager.Tasks
{
[DisplayName("Generate Update Dependencies")]
public class GenerateUpdateDependencies : Task
{
[Input("File paths to update", IOCardinality.Multi, IOType.String)]
public ReferenceList FilePathsToUpdate { get; set; }
[Output("Update File Paths", IOType.String)]
public ReferenceList UpdateFilePaths = new ReferenceList();
public GenerateUpdateDependencies()
{
FilePathsToUpdate = new ReferenceList();
}
protected override void StartInternal(BuildConfiguration profile, cookerWrapper cooker)
{
foreach (string path in FilePathsToUpdate)
{
//Create Unique File names in order to avoid cooker creating .txt's with same asset file names.
var tempFileSuffixWithExtension = path.Replace('/', '+');
var dirInfo = new DirectoryInfo(path);
var tempFilePath = path.Replace(dirInfo.Name, tempFileSuffixWithExtension);
var sourceFile = DataPath.GetAbsolutePath(path);
var destinationFile = DataPath.GetAbsolutePath(tempFilePath);
File.WriteAllText(destinationFile, File.ReadAllText(sourceFile));
UpdateFilePaths.Add(tempFilePath);
}
}
}
}