在编译包含它们的资源文件 (QRC) 之前,我想使用脚本来构建翻译(从 .ts 转换为 .qm,使用 Qt's )。lrelease.exe
通过这种方式,我知道它们总是会更新,更不用说避免在存储库中包含二进制文件。
我使用 Visual Studio 并安装了 Qt Visual Studio 工具。通常,我会通过项目中的预构建步骤来执行此操作,但它没有被执行,并且 QRC 文件的编译总是失败。
1>------ Build started: Project: MyApp, Configuration: Release Win32 ------
1>Rcc'ing MyApp.qrc...
1> RCC: Error in 'C:\src\MyApp\MyApp\MyApp.qrc': Cannot find file 'translations/myapp_en.qm'
1>MyApp.qrc : error 1: rcc (c:\Qt\qt_5_12_3\v141\Win32\bin\rcc.exe)
1>Done building project "MyApp.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 12 up-to-date, 1 skipped ==========
该脚本可以正常工作,如果作为构建后事件或从命令行放置,它会成功调用。
@echo off
pushd "%1"
for %%F in (*.ts) do (
c:\Qt\qt_5_12_3\v141\Win32\bin\lrelease -compress %%F -qm %%~nF.qm
)
popd
exit /b 0
我做错了什么?