现象

Visual Studio 编译 UE 项目失败,无任何错误日志输出,手动运行编译命令输出:

TEXT
...
Using 'git status' to determine working set for adaptive non-unity build (D:\Code\Unreal Projects\ShowreelOne).
Creating makefile for ShowreelOneEditor (no existing makefile)
点击展开查看更多

至此直接退出,无报错、无任何其他输出。 检查 UnrealBuildTool\Log.txt 发现日志突然“腰斩”,没有任何实质性的错误堆栈输出。


排查

如此看来像是 dotnet (UnrealBuildTool) 遇到错误直接闪退,转向检查 Windows 系统日志。 进入 Windows 日志 -> 应用程序,找到对应时间的 dotnet.exe 崩溃记录:

TEXT
Application: dotnet.exe
CoreCLR Version: 8.0.1825.31117
.NET Version: 8.0.18
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException: Path fragment '"Content/Ocean/\345\215\240\344\275\215RTArray.uasset"' contains invalid directory separators.
   at EpicGames.Core.FileSystemReference.CombineStrings(DirectoryReference baseDirectory, String[] fragments)
   at UnrealBuildTool.GitSourceFileWorkingSet.AddPath(String Path)
   at UnrealBuildTool.GitSourceFileWorkingSet.OutputDataReceived(Object Sender, DataReceivedEventArgs Args)
   at System.Diagnostics.AsyncStreamReader.FlushMessageQueue(Boolean rethrowInNewThread)
--- End of stack trace from previous location ---
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
点击展开查看更多

原因分析

这是一场由 UnrealBuildTool 和 Git 配合引发的崩溃:

  1. UnrealBuildTool 机制: 虚幻引擎的 UnrealBuildTool 为了加速编译,会在后台静默运行 git status 来获取工作区变动。
  2. Git 的默认转义: 当项目中存在中文命名的资产(如 占位RTArray.uasset)时,Git 默认会将非 ASCII 字符转义为带反斜杠和双引号的八进制乱码(即 \345\215...)。
  3. 解析崩溃: UBT 读取到这串乱码后,其路径解析器无法处理这些意外的反斜杠和双引号,直接抛出异常并导致进程瞬间死亡,连写日志的时间都没有。

解决方案

修改 Git 配置 让 Git 停止对中文路径进行八进制转义:

BASH
git config --global core.quotepath false
点击展开查看更多

版权声明

作者: Cheyne Xie

链接: https://chaim.eu.org/posts/fbb5eb9f/

许可证: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键