mirror of
https://github.com/dreamforceinc/wUpdateVersionPS.git
synced 2026-03-28 18:52:46 +03:00
Initial commit
This commit is contained in:
118
README.md
Normal file
118
README.md
Normal file
@@ -0,0 +1,118 @@
|
||||
# wUpdateVersionPS
|
||||
|
||||
Ñêðèïò PowerShell äëÿ àâòîìàòè÷åñêîãî îáíîâëåíèÿ íîìåðà âåðñèè ïðîãðàììû.
|
||||
|
||||
_**Ôàéë ðåñóðñîâ äîëæåí áûòü â ANSI èëè UTF-8 êîäèðîâêå.**_
|
||||
|
||||
|
||||
## Íàçíà÷åíèå ñêðèïòà ##
|
||||
`wUpdateVersionPS` ñëóæèò äëÿ àâòîìàòè÷åñêîãî îáíîâëåíèÿ âåðñèè ïðîãðàììû ïåðåä ýòàïîì êîìïèëÿöèè â ñðåäå ðàçðàáîòêè Microsoft Visual Studio. Ñêðèïò èçâëåêàåò çíà÷åíèå âåðñèè èç ôàéëà, ñîäåðæàùåãî ìàêðîñ èëè îïðåäåëåíèå `APP_VERSION`, è çàïèñûâàåò ýòó âåðñèþ â áëîê `VERSIONINFO` ôàéëà ðåñóðñîâ.
|
||||
|
||||
## ×òî äåëàåò ñêðèïò? ##
|
||||
|
||||
1. Èçâëåêàåò âåðñèþ ïðîãðàììû èç çàäàííîãî ôàéëà (*íàïðèìåð `version.h`*), ñîäåðæàùåãî ñòðîêó âèäà `#define APP_VERSION "X.Y.Z.W"`.
|
||||
|
||||
2. Îáíîâëÿåò â óêàçàííîì ôàéëå ðåñóðñîâ (*íàïðèìåð `resources.rc`*) áëîê `VERSIONINFO`, ñîäåðæàùèé ñòðîêè `FileVersion` è `ProductVersion`, ñîîòâåòñòâåííî.
|
||||
|
||||
## Êàê çàïóñòèòü ñêðèïò? ##
|
||||
|
||||
Çàïóñêàéòå ñêðèïò êîìàíäîé â êîíñîëè PowerShell:
|
||||
|
||||
```bash
|
||||
powershell.exe -ExecutionPolicy Bypass -File path\to\wUpdateVersionPS.ps1 arg1 arg2
|
||||
```
|
||||
Ïàðàìåòðû:
|
||||
|
||||
`path\to\wUpdateVersionPS.ps1`: Ïîëíûé ïóòü ê PowerShell-ñêðèïòó.
|
||||
|
||||
`arg1`: Ïóòü ê ôàéëó, ñîäåðæàùåìó îïðåäåëåíèå âåðñèè (`version.h`).
|
||||
|
||||
`arg2`: Ïóòü ê ôàéëó ðåñóðñîâ (`resources.rc`).
|
||||
|
||||
Íàïðèìåð:
|
||||
|
||||
```bash
|
||||
powershell.exe -ExecutionPolicy Bypass -File C:\Scripts\wUpdateVersionPS.ps1 C:\Project\version.h C:\Project\resources.rc
|
||||
```
|
||||
|
||||
## Àâòîìàòèçàöèÿ çàïóñêà ñêðèïòà ïåðåä ñáîðêîé ïðîåêòà ##
|
||||
|
||||
Âû ìîæåòå äîáàâèòü âûçîâ ñêðèïòà â êà÷åñòâå ïðåäêîìïèëÿöèîííîãî øàãà â ïðîåêòå Microsoft Visual Studio, âûïîëíèâ ñëåäóþùèå øàãè:
|
||||
|
||||
1. Ù¸ëêíèòå ïðàâîé êíîïêîé ìûøè ïî ïðîåêòó â Solution Explorer è âûáåðèòå ïóíêò Properties.
|
||||
|
||||
2. Ïåðåéäèòå íà âêëàäêó Build Events, ðàçäåë Pre-Build Event, Command Line.
|
||||
|
||||
3. Äîáàâüòå òóäà ñëåäóþùèé êîä:
|
||||
```bash
|
||||
powershell.exe -ExecutionPolicy Bypass -File "$(SolutionDir)wUpdateVersionPS.ps1" "$(ProjectDir)version.h" "$(ProjectDir)resources.rc"
|
||||
```
|
||||
> *Â äàííîì ïðèìåðå ñêðèïò `wUpdateVersionPS.ps1` íàõîäèòñÿ â ïàïêå ðåøåíèÿ, à ôàéëû `version.h` è `resources.rc` - â ïàïêå ïðîåêòà.*
|
||||
|
||||
4. Îáíîâèòå îïðåäåëåíèå ìàêðîñà `APP_VERSION` â ôàéëå `version.h` (Íàïðèìåð `APP_VERSION "1.0"` -> `APP_VERSION "1.1"`).
|
||||
|
||||
Òàêèì îáðàçîì, êàæäûé ðàç ïåðåä êîìïèëÿöèåé ïðîåêòà âåðñèÿ ïðîãðàììû áóäåò àâòîìàòè÷åñêè îáíîâëÿòüñÿ.
|
||||
|
||||
_(c) 2026 Vladislav Salikov aka W0LF aka 'dreamforce'_
|
||||
|
||||
> _Ýòîò òåêñò ñîçäàí ñ ïîìîùüþ Giga.Chat._
|
||||
-----
|
||||
|
||||
|
||||
# wUpdateVersionPS
|
||||
|
||||
A PowerShell script for automatically updating the program version number.
|
||||
|
||||
_**The resource file must be in ANSI or UTF-8 encoding.**_
|
||||
|
||||
## Script Purpose ##
|
||||
`wUpdateVersionPS` is used to automatically update the program version before compilation in the Microsoft Visual Studio IDE. The script extracts the version value from a file containing the `APP_VERSION` macro or definition and writes this version to the `VERSIONINFO` block of the resource file.
|
||||
|
||||
## What does the script do? ##
|
||||
|
||||
1. Extracts the program version from the specified file (*e.g. `version.h`*) containing the string `#define APP_VERSION "X.Y.Z.W"`.
|
||||
|
||||
2. Updates the `VERSIONINFO` block in the specified resource file (*e.g. `resources.rc`*) containing the strings `FileVersion` and `ProductVersion`, respectively.
|
||||
|
||||
## How do I run the script? ##
|
||||
|
||||
Run the script with the following command in the PowerShell console:
|
||||
|
||||
```bash
|
||||
powershell.exe -ExecutionPolicy Bypass -File path\to\wUpdateVersionPS.ps1 arg1 arg2
|
||||
```
|
||||
Parameters:
|
||||
|
||||
`path\to\wUpdateVersionPS.ps1`: Full path to the PowerShell script.
|
||||
|
||||
`arg1`: Path to the file containing the version definition (`version.h`).
|
||||
|
||||
`arg2`: Path to the resource file (`resources.rc`).
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
powershell.exe -ExecutionPolicy Bypass -File C:\Scripts\wUpdateVersionPS.ps1 C:\Project\version.h C:\Project\resources.rc
|
||||
```
|
||||
|
||||
## Automating the execution of a script before building a project ##
|
||||
|
||||
You can add a script call as a pre-compile step in a Microsoft Visual Studio IDE by following these steps:
|
||||
|
||||
1. Right-click the project in Solution Explorer and select Properties.
|
||||
|
||||
2. Go to the Build Events tab, Pre-Build Event section, Command Line.
|
||||
|
||||
3. Add the following code there:
|
||||
```bash
|
||||
powershell.exe -ExecutionPolicy Bypass -File "$(SolutionDir)wUpdateVersionPS.ps1" "$(ProjectDir)version.h" "$(ProjectDir)resources.rc"
|
||||
```
|
||||
> *In this example, the `wUpdateVersionPS.ps1` script is located in the solution folder, and the `version.h` and `resources.rc` files are in the project folder.*
|
||||
|
||||
4. Update the definition of the `APP_VERSION` macro in the `version.h` file (e.g. `APP_VERSION "1.0"` -> `APP_VERSION "1.1"`).
|
||||
|
||||
This way, the program version will be automatically updated every time the project is compiled.
|
||||
|
||||
_(c) 2026 Vladislav Salikov aka W0LF aka 'dreamforce'_
|
||||
|
||||
> _This text was created using Giga.Chat._
|
||||
Reference in New Issue
Block a user