@openssl
您好,请告知一下您的使用方法(命令行参数)
输出eproject文件的同目录的src文件夹会被认为是源代码输出目录(如果手动设置了source-set参数,则目录名为其他),其中的代码文件(*.ecode/*.eform)和资源文件(@Resource子文件夹下)会在 generate 时被自动清除然后重新生成
相关的代码逻辑参见开源仓库的 TextECodeGenerator.cs#L241-L277
[C#] 纯文本查看 复制代码 public TextECodeGenerator DeleteNonGeneratedFiles()
{
var srcBase = new DirectoryInfo(SrcBasePath);
var NonGeneratedECodes = srcBase.GetFiles("*.ecode", SearchOption.AllDirectories)
.Where(x => !GeneratedPaths.Contains(x.FullName));
var NonGeneratedEForms = srcBase.GetFiles("*.eform", SearchOption.AllDirectories)
.Where(x => !GeneratedPaths.Contains(x.FullName));
var NonGeneratedResources = srcBase.GetDirectories("@Resource", SearchOption.AllDirectories)
.SelectMany(x => x.EnumerateFiles())
.Where(x => !GeneratedPaths.Contains(x.FullName));
foreach (var item in NonGeneratedECodes.Concat(NonGeneratedEForms).Concat(NonGeneratedResources))
{
try
{
item.Delete();
}
catch (Exception e)
{
logger.LogError(e, "无法删除文件 \"{Path}\"", item.FullName);
}
}
var NonGeneratedEmptyDirectories = srcBase.GetDirectories("*", SearchOption.AllDirectories)
.Where(x => !GeneratedPaths.Contains(x.FullName))
.Where(x => x.EnumerateFiles().FirstOrDefault() == null);
foreach (var item in NonGeneratedEmptyDirectories)
{
try
{
item.Delete();
}
catch (Exception e)
{
logger.LogError(e, "无法删除目录 \"{Path}\"", item.FullName);
}
}
return this;
} |