- Fixed bug in builder when no content files exist
This commit is contained in:
parent
dd3bbf1d5b
commit
d45f7c3b8c
@ -37,65 +37,69 @@ public void Run(BuildArgs args)
|
|||||||
CollectAssetFiles(absContentPath, absContentPath, ref contentFiles);
|
CollectAssetFiles(absContentPath, absContentPath, ref contentFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
string importPath = $"{args.ProjectPath}/{PathUtil.ImportFolderName}";
|
if (contentFiles.Count > 0)
|
||||||
|
|
||||||
ParallelOptions parallelOptions = new ParallelOptions
|
|
||||||
{
|
{
|
||||||
MaxDegreeOfParallelism = contentFiles.Count
|
string importPath = $"{args.ProjectPath}/{PathUtil.ImportFolderName}";
|
||||||
};
|
|
||||||
Parallel.ForEach(contentFiles, parallelOptions, relativeFile =>
|
ParallelOptions parallelOptions = new ParallelOptions
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
string inFile = $"{args.ProjectPath}/{PathUtil.ContentFolderName}/{relativeFile}";
|
MaxDegreeOfParallelism = contentFiles.Count
|
||||||
|
};
|
||||||
|
|
||||||
if (!File.Exists(inFile))
|
Parallel.ForEach(contentFiles, parallelOptions, relativeFile =>
|
||||||
{
|
|
||||||
Console.Error.WriteLine($"Asset file '{relativeFile}' not found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string outFile = $"{importPath}/{relativeFile}{PathUtil.ImportedFileExtension}";
|
|
||||||
|
|
||||||
FileInfo inFileInfo = new FileInfo(inFile);
|
|
||||||
FileInfo outFileInfo = new FileInfo(outFile);
|
|
||||||
|
|
||||||
if (!FileUtil.IsNewer(inFileInfo, outFileInfo))
|
|
||||||
{
|
|
||||||
// File has not changed since last build, no need to build this one.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string outDir = Path.GetDirectoryName(outFile);
|
|
||||||
if (!Directory.Exists(outDir))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(outDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
string ext = Path.GetExtension(inFile).ToLower();
|
|
||||||
if (importers.TryGetValue(ext, out IImporter importer))
|
|
||||||
{
|
|
||||||
importer.Import(inFile, outFile);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rawFileImporter.Import(inFile, outFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine(relativeFile);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine($"Import error on asset '{relativeFile}': {e.Message}");
|
try
|
||||||
}
|
{
|
||||||
});
|
string inFile = $"{args.ProjectPath}/{PathUtil.ContentFolderName}/{relativeFile}";
|
||||||
|
|
||||||
|
if (!File.Exists(inFile))
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"Asset file '{relativeFile}' not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string outFile = $"{importPath}/{relativeFile}{PathUtil.ImportedFileExtension}";
|
||||||
|
|
||||||
|
FileInfo inFileInfo = new FileInfo(inFile);
|
||||||
|
FileInfo outFileInfo = new FileInfo(outFile);
|
||||||
|
|
||||||
|
if (!FileUtil.IsNewer(inFileInfo, outFileInfo))
|
||||||
|
{
|
||||||
|
// File has not changed since last build, no need to build this one.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string outDir = Path.GetDirectoryName(outFile);
|
||||||
|
if (!Directory.Exists(outDir))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(outDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
string ext = Path.GetExtension(inFile).ToLower();
|
||||||
|
if (importers.TryGetValue(ext, out IImporter importer))
|
||||||
|
{
|
||||||
|
importer.Import(inFile, outFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rawFileImporter.Import(inFile, outFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine(relativeFile);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"Import error on asset '{relativeFile}': {e.Message}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine($"Build content completed in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
|
Console.WriteLine($"Build content completed in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CopyLibs(string projectPath)
|
private void CopyLibs(string projectPath)
|
||||||
{
|
{
|
||||||
string libDir = $"{Directory.GetCurrentDirectory()}/../../Native/";
|
string libDir = $"{AppDomain.CurrentDomain.BaseDirectory}/../../Native/";
|
||||||
if (OperatingSystem.IsWindows())
|
if (OperatingSystem.IsWindows())
|
||||||
{
|
{
|
||||||
libDir += "x64";
|
libDir += "x64";
|
||||||
|
@ -27,4 +27,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Import Project=".\CopyLibs.targets"/>
|
<Import Project=".\CopyLibs.targets"/>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command=""$(ProjectDir)../Tools/Nerfed.Builder/Nerfed.Builder" -build -projectPath $(ProjectDir) -platform Desktop" />
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user