Modifying only one field property of win32 exe - windows

For a release pipeline I need to update the ProductVersion field of a win32 exe. All the other fields are updated in the build pipeline of each application. The release pipeline covers multiple applications and bundling them into an archive, which should be tagged with a new version.
The property of the exe prior to release pipeline is shown below and the only field left to fill is ProductVersion.
There are numerous exe's like such and I just need to update the Product version. I am able to update that field using a Resources.rc file and the tool ResourceHacker, but I need to include info on all the other fields too, which is not possible during a release build as the file version info is not known at the time. i.e
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,2,3,5
PRODUCTVERSION 1,2,3,5
{
BLOCK "StringFileInfo"
{
BLOCK "040904b0"
{
VALUE "CompanyName", "Tester.\0"
VALUE "FileDescription", "Test Application for release\0"
VALUE "FileVersion", "1.2.3.5\0"
VALUE "LegalCopyright", "2023 Copyright Notice. All rights reserved\0"
VALUE "ProductName", "TestRelease\0"
VALUE "ProductVersion", "2.2.2.2\0"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1200
}
}
I thought just including the productversion in the rc file would work and ignore updating the other fields but it just cleaned all the properties like below.
VS_VERSION_INFO VERSIONINFO
PRODUCTVERSION 2,2,2,2
{
BLOCK "StringFileInfo"
{
BLOCK "040904b0"
{
VALUE "ProductVersion", "2.2.2.2\0"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1200
}
}

Related

Saving values of debug session from watch window to a file

I have to trace some events I want to trace to monitor the operation of a multi-threaded application. For this purpose I defined an array of structs. Each element is one trace record.
enum Event { start, stop, pause };
struct A
{
Event e;
int x, y, z;
};
main()
{
A a[100];
}
There is also a function the writes the event to the array. The array a can be displayed in the watch window of Visual Studio, although not all struct members are displayed:
- a 0x008ff4bc {{e=0xcccccccc x=0xcccccccc y=0xcccccccc ...}, {e=0xcccccccc x=0xcccccccc y=0xcccccccc ...}, ...} A[0x00000064]
+ [0x00000000] {e=0xcccccccc x=0xcccccccc y=0xcccccccc ...} A
+ [0x00000001] {e=0xcccccccc x=0xcccccccc y=0xcccccccc ...} A
+ [0x00000002] {e=0xcccccccc x=0xcccccccc y=0xcccccccc ...} A
Since the array is rather large and the limitation of the watch I want to export the entire array content to a file. This could be done by adding a file export function to the code that is being debugged. But this is no handy, since the debugger is just in a breakpoint and it's not always possible to tell the application to run the export function.
How can I export the array with the values of all members? Is there an option to use the VS command window or probably immediate window to create a text file with the data?
Does it have to be a one-click export? You can select all, copy and paste into your output file. You can do it from Watch window, but the output is a bit more clear from either Immediate or Command windows.
You can beautify the format by creating a custom visualizer in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger\Visualizers (use your version of the VS).
Here is how it may look, for example:
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="A">
<DisplayString>({e}:{x},{y},{z})</DisplayString>
</Type>
</AutoVisualizer>

Xcode: Lazy variable value not available in debugger

Why is a lazy variable not available for inspection in the Xcode debugger?
var d: Date? {
return Date()
}
let date = d
// Set breakpoint here
At the breakpoint the variable inspector in Xcode shows value Date? for variable date. When trying to print the description of the variable the lldb console prints:
Printing description of date:
(Date?) date = <variable not available>
Build Settings > Optimization Level is set to -Onone for debug and the scheme's Build Configuration is set to Debug.

Pug: compilation of extended blocks in a condition

I recently moved from Jade to Pug and I encountered a problem compiling my code. The code of a block inserted in a condition is no longer called, only the alternate message ([content]) is returned :
// PatternLayouts.pug
block var
//- Default values
// [etc...]
- contentlarge = false
main(itemprop='mainContentOfPage')
if contentlarge
block content
// Default
p [Content]
else
.section
.wrap
h1(itemprop='headline name').emphasized= name
block content
// Default
p [Content]
If variable contentlarge = false then no interpretation problem, but if this is equal to true the code defined by the alternative condition (else) does not work ...
I finally found, it is actually a regression of functionality: Github, issue # 2367

Update value according to build type in Gradle

I am using Android Studio with Gradle build.
In my build.gradle, I want a variable's value to be different for different build type:
ext {
//By default, the value of myVar is 'debug'
myVar = 'debug'
}
android {
buildTypes {
release {
//update value of myVar to 'release'
project.ext.set("myVar","release")
}
debug {
//update value of myVar to 'debug'
project.ext.set("myVar","debug")
}
}
}
//I defined a task to check the value of myVar
task checkVar () {
println "My var is $myVar"
}
check.dependsOn(checkVar)
When I run command gradle clean assembleRelease , I expected to see a print out text My var is release. But, I see My var is debug . Why the value of myVar is not changed to release ?
What I want to achieve is to get the current build type during execution. Is there a better way to achieve this?
This won't work as it is a project scoped variable. the build type blocks are just configuration, so what really happens here (a bit simplified though):
You declare a variable named 'myVar' with a default value 'debug' assigned
You run the release configuration block and set the value of 'myVar' to 'release'
You run the debug configuration block and set the value of 'myVar' back to 'debug'
when executing the 'checkVar' task, the last assigned value is printed.
FYI: you can simplify 2. and 3. by just calling project.myVar = 'whatever'

When I really should call refresh function in module curses in Ruby

When I really should call refresh function manually in module Curses in Ruby? I think that it's unclear in the docs.
Thanks in advance.
The refresh method points out to the external function refresh():
static VALUE
curses_refresh(VALUE obj)
{
curses_stdscr();
refresh();
return Qnil;
}
And you can see the documentation of that refresh() method in the curs_refresh manual:
The refresh and wrefresh routines (or wnoutrefresh and doupdate) must
be called to get actual output to the terminal, as other routines mere‐
ly manipulate data structures. The routine wrefresh copies the named
window to the physical terminal screen, taking into account what is al‐
ready there to do optimizations. The refresh routine is the same, us‐
ing stdscr as the default window. Unless leaveok has been enabled, the
physical cursor of the terminal is left at the location of the cursor
for that window.
In modern Linux you can see the declaration of that function or macros in /usr/include/ncurses.h or /usr/include/curses.h. Example:
extern NCURSES_EXPORT(int) refresh (void); /* generated */
#define refresh() wrefresh(stdscr)
And this is the part of Ruby's curses.c that refers to the header files:
#if defined(HAVE_NCURSES_H)
# include <ncurses.h>
#elif defined(HAVE_NCURSES_CURSES_H)
# include <ncurses/curses.h>
#elif defined(HAVE_CURSES_COLR_CURSES_H)
# ifdef HAVE_STDARG_PROTOTYPES
# include <stdarg.h>
# else
# include <varargs.h>
# endif
# include <curses_colr/curses.h>
#else
# include <curses.h>
...
# endif
#endif

Resources