I have a c++ project solution which i am building using azure devops pipeline and i want to update the file version everytime my build is sucessful. I have found different extensions but none is working for me.
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "xxxxx"
BEGIN
VALUE "CompanyName", "xxxx"
VALUE "FileDescription", "xxxx"
VALUE "FileVersion", "1.1.0.0"
VALUE "InternalName", "xxxxx"
VALUE "LegalCopyright", "xxxxx"
VALUE "OriginalFilename", "xxxx"
VALUE "ProductName", "xxxxx"
VALUE "ProductVersion", "1.1.0.0"
END
END
this is how my .rc file looks where i set my default version and other things. I am looking for a way on how i can update fileversion and product version eveytime i build.
Try using the Replace Text in Source Files extension. Just add two Replace In Files Text By Text
tasks to replace the FileVersion
and ProductVersion
separately.
You can set your file and product version variables for the update. Also search the *.rc file by a pattern or specify the particular *.rc file in the Advance option.
Below YAML for your reference:
variables:
FileVersion : 2.2.0.1 #This is just a sample, you can set and use the value dynamically like the build number.
ProductVersion : 2.3.0.2
pool:
vmImage: windows-latest
steps:
- task: ReplaceInFilesTextByText@2
displayName: Replace-FileVersion
inputs:
parameterSearchDirectory: '$(Build.SourcesDirectory)'
parameterSearchText: '"FileVersion", "1.1.0.0"'
parameterReplaceText: '"FileVersion", "$(FileVersion)"'
parameterTypeOfSearch: 'filesSearchPattern'
parameterFilesPattern: '*.rc'
- task: ReplaceInFilesTextByText@2
displayName: Replace-ProductVersion
inputs:
parameterSearchDirectory: '$(Build.SourcesDirectory)'
parameterSearchText: '"ProductVersion", "1.1.0.0"'
parameterReplaceText: '"ProductVersion", "$(ProductVersion)"'
parameterTypeOfSearch: 'filesSearchPattern'
parameterFilesPattern: '*.rc'
- task: PowerShell@2
displayName: Check-Modified-rc-file
inputs:
targetType: 'inline'
script: 'cat $(Build.SourcesDirectory)\test.rc'
As we can see the versions can be updated successfully:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.