diff --git a/GitVer/GitVer_pyinstaller.cpp b/GitVer/GitVer_pyinstaller.cpp index d0b45e8..978b7b9 100644 --- a/GitVer/GitVer_pyinstaller.cpp +++ b/GitVer/GitVer_pyinstaller.cpp @@ -411,23 +411,49 @@ static BOOL UpdateVersionInfoFile(LPCTSTR lpPath, LPCTSTR lpProductVersion, LPCT { const std::string key = "u'FileVersion', u'"; 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 pValEnd = s.find('\'', pValStart); + if (pValEnd != std::string::npos) + s.replace(pValStart, pValEnd - pValStart, szFileVer); + } + } } // 更新 ProductVersion 字符串值 { const std::string key = "u'ProductVersion', u'"; 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, 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; @@ -547,7 +573,7 @@ int HandlePyinstallerBuildCommand(int argc, TCHAR* argv[]) _tprintf(_T("FileVersion=%s\n"), strFileVersion.GetString()); 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); strCmd.ReleaseBuffer(); diff --git a/README.md b/README.md index c680f79..d4015de 100644 --- a/README.md +++ b/README.md @@ -443,14 +443,14 @@ VSVersionInfo( StringTable( '040904B0', # 璇█ 0409=鑻辫, 04B0=Unicode [ - StringStruct('CompanyName', 'MyCompany'), - StringStruct('FileDescription', 'MyApp Application'), - StringStruct('FileVersion', '5.0.1920.11'), - StringStruct('InternalName', 'MyApp'), - StringStruct('LegalCopyright', 'Copyright (C) 2026 MyCompany'), + StringStruct('CompanyName', 'MyCompany'), + StringStruct('FileDescription', 'MyApp Application'), + StringStruct('FileVersion', '5.0.1920.11'), + StringStruct('InternalName', 'MyApp'), + StringStruct('LegalCopyright', 'Copyright (C) 2026 MyCompany'), StringStruct('OriginalFilename', 'MyApp.exe'), - StringStruct('ProductName', 'MyApp'), - StringStruct('ProductVersion', '5.0.1920.11'), + StringStruct('ProductName', 'MyApp'), + StringStruct('ProductVersion', '5.0.1920.11'), ] ) ]),