修复pyinstaller打包后,版本信息不对的问题。
This commit is contained in:
@@ -411,23 +411,49 @@ static BOOL UpdateVersionInfoFile(LPCTSTR lpPath, LPCTSTR lpProductVersion, LPCT
|
|||||||
{
|
{
|
||||||
const std::string key = "u'FileVersion', u'";
|
const std::string key = "u'FileVersion', u'";
|
||||||
auto p = s.find(key);
|
auto p = s.find(key);
|
||||||
if (p != std::string::npos) {
|
if (p != std::string::npos)
|
||||||
|
{
|
||||||
|
auto pValStart = p + key.size();
|
||||||
|
auto pValEnd = s.find('\'', pValStart);
|
||||||
|
if (pValEnd != std::string::npos)
|
||||||
|
s.replace(pValStart, pValEnd - pValStart, szFileVer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{// 可能不带u
|
||||||
|
const std::string key = "'FileVersion', '";
|
||||||
|
auto p = s.find(key);
|
||||||
|
if (p != std::string::npos)
|
||||||
|
{
|
||||||
auto pValStart = p + key.size();
|
auto pValStart = p + key.size();
|
||||||
auto pValEnd = s.find('\'', pValStart);
|
auto pValEnd = s.find('\'', pValStart);
|
||||||
if (pValEnd != std::string::npos)
|
if (pValEnd != std::string::npos)
|
||||||
s.replace(pValStart, pValEnd - pValStart, szFileVer);
|
s.replace(pValStart, pValEnd - pValStart, szFileVer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 更新 ProductVersion 字符串值
|
// 更新 ProductVersion 字符串值
|
||||||
{
|
{
|
||||||
const std::string key = "u'ProductVersion', u'";
|
const std::string key = "u'ProductVersion', u'";
|
||||||
auto p = s.find(key);
|
auto p = s.find(key);
|
||||||
if (p != std::string::npos) {
|
if (p != std::string::npos)
|
||||||
|
{
|
||||||
auto pValStart = p + key.size();
|
auto pValStart = p + key.size();
|
||||||
auto pValEnd = s.find('\'', pValStart);
|
auto pValEnd = s.find('\'', pValStart);
|
||||||
if (pValEnd != std::string::npos)
|
if (pValEnd != std::string::npos)
|
||||||
s.replace(pValStart, pValEnd - pValStart, szProdVer);
|
s.replace(pValStart, pValEnd - pValStart, szProdVer);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{//可能不带u
|
||||||
|
const std::string key = "'ProductVersion', '";
|
||||||
|
auto p = s.find(key);
|
||||||
|
if (p != std::string::npos)
|
||||||
|
{
|
||||||
|
auto pValStart = p + key.size();
|
||||||
|
auto pValEnd = s.find('\'', pValStart);
|
||||||
|
if (pValEnd != std::string::npos)
|
||||||
|
s.replace(pValStart, pValEnd - pValStart, szProdVer);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!myFile.Open(lpPath, CFile::modeCreate | CFile::modeWrite, &fileEx)) return FALSE;
|
if (!myFile.Open(lpPath, CFile::modeCreate | CFile::modeWrite, &fileEx)) return FALSE;
|
||||||
@@ -547,7 +573,7 @@ int HandlePyinstallerBuildCommand(int argc, TCHAR* argv[])
|
|||||||
_tprintf(_T("FileVersion=%s\n"), strFileVersion.GetString());
|
_tprintf(_T("FileVersion=%s\n"), strFileVersion.GetString());
|
||||||
|
|
||||||
CString strCmd;
|
CString strCmd;
|
||||||
strCmd.Format(_T("cmd /c python -m PyInstaller %s"),strExtraArgs.GetString());
|
strCmd.Format(_T("cmd /c python -m PyInstaller %s"), strExtraArgs.GetString());
|
||||||
|
|
||||||
CString strBuildResult = StartProcess(NULL, strCmd.GetBuffer(), lpRepoPath);
|
CString strBuildResult = StartProcess(NULL, strCmd.GetBuffer(), lpRepoPath);
|
||||||
strCmd.ReleaseBuffer();
|
strCmd.ReleaseBuffer();
|
||||||
|
|||||||
Reference in New Issue
Block a user