Normally when writing something that requires padding, we first measure the length of the written payload data, then write padding if necessary.
For a recursive structure like versioninfo, this means that the padding is excluded from the size of the inner element, but included in the size of the enclosing block.
Rc.exe excludes the final padding (but not the padding of earlier children) from all levels of the hierarchy.
To achieve this, don't pad after each block or value, but only before starting the next one. We still pad after completing the toplevel versioninfo resource, so this won't affect other resource types.