I'm pleased to announce the release of pg_msvc_generator, version 1.0.0 beta.
pg_msvc_generator is a new tool created to help extension authors to provide Windows versions of their extensions. It's written in Perl and is open source with a PostgreSQL license.
This tool is composed of 2 scripts:
pg_msvc_generator.pl script will generate an msvc subdirectory in the given extension directory, containing the required .sln and .vcxproj files to be able to compile the extension using Visual Studio 2019, with support for Debug/Release and 32/64 bits builds. It will also create copy the
release.pl and generate a
build.bat scripts that can automatically compile and create release archive files and installers for all locally installed PostgreSQL versions.
pg_msvc_generator.pl [ options ] Options: --default version pgver : default PostgreSQL version. This is only used if you compile the project without specifying a specific major version, or when the project is opened with Visual Studio IDE. If not provided, a default value based on the year will be chosen (13 for 2021, 14 for 2022 and so on). -d | --dir ext_directory : root directory of the extension source code. -e | --extension : extension name. If not provided, the extension name will be assumed using the last part of the given root directory. -h | --help : Show this message.
pg_msvc_generator.pl -d C:\git\hypopg
At project generation time:
At extension compilation time:
All you need to do is to execute the
msvc\release.bat script. It will setup
the MSVC environment and call the
release.pl script. That script will
prepare everything for a release under a
It will automatically find the installed PostgreSQL version reading the
HKLM/SOFTWARE/PostgreSQL/Installations/ registry, compile the extension with
all those versions and for each will generate a subdirectory containing the dll
and the SQL scripts if any, a zip archive with the same content and optionally an installer.
For instance, assuming that you have PostgreSQL 12 and 13 installed and
released HypoPG 1.3.2 and NSIS installed, your
msvc directory will now have
this additional content:
If you have NSIS installed in the default
C:\Program Files (x86)\NSIS), the
release.pl script will generate
.nsi file and compile it using makensis.exe to generate an specific
installer for each PostgreSQL major versions found when running the
release.pl script. At execution time, the installer will try to discover the
server's PostgreSQL installation path by reading the registry key
If the key is found, the installer will inform the user and use it as the default installation location. Otherwise, the installer will inform the user that no installation was automatically found and will force the user to choose a location before being able to continue the installation.