From 84d67d9709949f3f105b5245f10d730435a8f6e7 Mon Sep 17 00:00:00 2001 From: Jeff <632006142@qq.com> Date: Wed, 20 May 2026 20:16:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpyinstaller=E6=89=93=E5=8C=85?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF=E4=B8=8D?= =?UTF-8?q?=E5=AF=B9=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GitVer/GitVer_pyinstaller.cpp | 32 +++++++++++++++++++++++++++++--- README.md | 14 +++++++------- 2 files changed, 36 insertions(+), 10 deletions(-) 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'), ] ) ]),