MSVC Build support with visual studio 2019

Started by Haribabu Kommialmost 7 years ago21 messages
#1Haribabu Kommi
kommi.haribabu@gmail.com
1 attachment(s)

Hi Hackers,

Here I attached a patch that supports building of PostgreSQL with VS 2019.
VS 2019 is going to release on Apr 2nd 2019, it will be good if version 12
supports compiling. The attached for is for review, it may needs some
updates
once the final version is released.

Commit d9dd406fe281d22d5238d3c26a7182543c711e74 has reduced the
minimum visual studio support to 2013 to support C99 standards, because of
this
reason, the current attached patch cannot be backpatched as it is.

I can provide a separate back branches patch later once this patch comes to
a stage of commit. Currently all the supported branches are possible to
compile with VS 2017.

comments?

Regards,
Haribabu Kommi
Fujitsu Australia

Attachments:

0001-Support-building-with-visual-studio-2019.patchapplication/octet-stream; name=0001-Support-building-with-visual-studio-2019.patchDownload
From e2cb6e37671c283c31ef5494012ec462f3fb87ec Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Wed, 20 Mar 2019 18:35:56 +1100
Subject: [PATCH] Support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 22 +++++++++--------
 src/tools/msvc/MSBuildProject.pm  | 25 +++++++++++++++++++
 src/tools/msvc/README             | 10 ++++----
 src/tools/msvc/Solution.pm        | 28 +++++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 41 ++++++++++++++++++++++++-------
 5 files changed, 102 insertions(+), 24 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index 22a2ffd55e..cc5c9e81da 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2013 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2013 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -69,24 +69,24 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 8.1a to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 8.1a to 10 or
   <productname>Visual Studio 2013</productname> and above. Compilation
   is supported down to <productname>Windows 7</productname> and
   <productname>Windows Server 2008 R2 SP1</productname> when building with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname>.
+  <productname>Visual Studio 2019</productname>.
    <!--
        For 2013 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2013-sysrequirements-vs
@@ -94,6 +94,8 @@
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2015-sysrequirements-vs
        For 2017 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2017-system-requirements-vs
+       For 2019 requirements:
+       https://docs.microsoft.com/en-us/visualstudio/releases/2019/system-requirements
    -->
  </para>
 
@@ -166,7 +168,7 @@ $ENV{MSBFLAGS}="/m";
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></ulink>.
      </para>
      <para>
@@ -175,7 +177,7 @@ $ENV{MSBFLAGS}="/m";
       If you install a <productname>Windows SDK</productname>
       including the <application>Visual C++ Compilers</application>,
       you don't need <productname>Visual Studio</productname> to build.
-      Note that as of Version 8.0a the Windows SDK no longer ships with a
+      Note that as of Version 8.1a the Windows SDK no longer ships with a
       complete command-line build environment.
      </para></listitem>
     </varlistentry>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 149213378c..ca965bdf1a 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -467,4 +467,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(MSBuildProject);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 4ab81d3402..45d71541fc 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2013 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2013 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -89,10 +89,10 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 (Mkvcbuild.pm) which creates the Visual Studio project and solution files.
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2013Project or VC2015Project or VC2017Project from
-MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing
+the corresponding Project interface (VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild) is
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 90a8d69e99..7ce440e314 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -889,6 +889,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2017 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.32.32432';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 1a94cd866e..b39e51f2da 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -39,15 +39,24 @@ sub CreateSolution
 		return new VS2015Solution(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
+	# visual 2017 nmake version is greather than 14.10 and less than 14.20.
+	# so adjust the check to support it.
 	elsif (($visualStudioVersion ge '14.10')
-		or ($visualStudioVersion eq '15.00'))
+		and ($visualStudioVersion lt '14.20'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# so adjust the check to support it.
+	elsif (($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -70,15 +79,28 @@ sub CreateProject
 		return new VC2015Project(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -106,18 +128,19 @@ sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
 
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual stuido that is suppored nmake version is >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
 		  "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
 		return '14.00';
 	}
-	elsif ($major < 6)
+	elsif ($major < 12)
 	{
 		croak
-		  "Unable to determine Visual Studio version: Visual Studio versions before 6.0 aren't supported.";
+		  "Unable to determine Visual Studio version: Visual Studio versions before 12.0 aren't supported.";
 	}
+
 	return "$major.$minor";
 }
 
-- 
2.20.1.windows.1

#2Michael Paquier
michael@paquier.xyz
In reply to: Haribabu Kommi (#1)
Re: MSVC Build support with visual studio 2019

On Thu, Mar 21, 2019 at 11:36:42AM +1100, Haribabu Kommi wrote:

I can provide a separate back branches patch later once this patch comes to
a stage of commit. Currently all the supported branches are possible to
compile with VS 2017.

When it comes to support newer versions of MSVC, we have come up
lately to backpatch that down to two stable versions but not further
down (see f2ab389 for v10 and v9.6), so it looks sensible to target
v11 and v10 as well if we were to do it today, and v11/v12 if we do it
in six months per the latest trends.
--
Michael

#3Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#2)
Re: MSVC Build support with visual studio 2019

On Thu, Mar 21, 2019 at 09:47:02AM +0900, Michael Paquier wrote:

When it comes to support newer versions of MSVC, we have come up
lately to backpatch that down to two stable versions but not further
down (see f2ab389 for v10 and v9.6), so it looks sensible to target
v11 and v10 as well if we were to do it today, and v11/v12 if we do it
in six months per the latest trends.

By the way, you mentioned upthread that all the branches can compile
with MSVC 2017, but that's not actually the case for 9.5 and 9.4 if
you don't back-patch f2ab389 further down. Or did you mean that the
code as-is is compilable if the scripts are patched manually?
--
Michael

#4Haribabu Kommi
kommi.haribabu@gmail.com
In reply to: Michael Paquier (#3)
Re: MSVC Build support with visual studio 2019

On Thu, Mar 21, 2019 at 12:31 PM Michael Paquier <michael@paquier.xyz>
wrote:

On Thu, Mar 21, 2019 at 09:47:02AM +0900, Michael Paquier wrote:

When it comes to support newer versions of MSVC, we have come up
lately to backpatch that down to two stable versions but not further
down (see f2ab389 for v10 and v9.6), so it looks sensible to target
v11 and v10 as well if we were to do it today, and v11/v12 if we do it
in six months per the latest trends.

By the way, you mentioned upthread that all the branches can compile
with MSVC 2017, but that's not actually the case for 9.5 and 9.4 if
you don't back-patch f2ab389 further down.

The commit f2ab389 is later back-patch to version till 9.3 in commit
19acfd65.
I guess that building the windows installer for all the versions using the
same
visual studio is may be the reason behind that back-patch.

Regards,
Haribabu Kommi
Fujitsu Australia

#5Michael Paquier
michael@paquier.xyz
In reply to: Haribabu Kommi (#4)
Re: MSVC Build support with visual studio 2019

On Thu, Mar 21, 2019 at 12:45:57PM +1100, Haribabu Kommi wrote:

The commit f2ab389 is later back-patch to version till 9.3 in commit
19acfd65. I guess that building the windows installer for all the
versions using the same visual studio is may be the reason behind
that back-patch.

I did not remember this one, thanks for pointing it out. So my
memories on that were incorrect. If it is possible to get the code to
build with MSVC 2019 on all the supported branches, we could do so.
--
Michael

#6Andrew Dunstan
andrew.dunstan@2ndquadrant.com
In reply to: Michael Paquier (#5)
Re: MSVC Build support with visual studio 2019

On 3/21/19 3:13 AM, Michael Paquier wrote:

On Thu, Mar 21, 2019 at 12:45:57PM +1100, Haribabu Kommi wrote:

The commit f2ab389 is later back-patch to version till 9.3 in commit
19acfd65. I guess that building the windows installer for all the
versions using the same visual studio is may be the reason behind
that back-patch.

I did not remember this one, thanks for pointing it out. So my
memories on that were incorrect. If it is possible to get the code to
build with MSVC 2019 on all the supported branches, we could do so.

VS2019 is currently in preview. I think we'd probably be better off
waiting until the full release. I don't know of any pressing urgency for
us to support it.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#7Andrew Dunstan
andrew.dunstan@2ndquadrant.com
In reply to: Andrew Dunstan (#6)
Re: MSVC Build support with visual studio 2019

I

On 3/25/19 3:44 PM, Andrew Dunstan wrote:

On 3/21/19 3:13 AM, Michael Paquier wrote:

On Thu, Mar 21, 2019 at 12:45:57PM +1100, Haribabu Kommi wrote:

The commit f2ab389 is later back-patch to version till 9.3 in commit
19acfd65. I guess that building the windows installer for all the
versions using the same visual studio is may be the reason behind
that back-patch.

I did not remember this one, thanks for pointing it out. So my
memories on that were incorrect. If it is possible to get the code to
build with MSVC 2019 on all the supported branches, we could do so.

VS2019 is currently in preview. I think we'd probably be better off
waiting until the full release. I don't know of any pressing urgency for
us to support it.

I see Haribabu mentioned that in his original email.

I'll take a look at verifying the patch.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#8Andrew Dunstan
andrew.dunstan@2ndquadrant.com
In reply to: Haribabu Kommi (#1)
Re: MSVC Build support with visual studio 2019

On 3/20/19 8:36 PM, Haribabu Kommi wrote:

Hi Hackers,

Here I attached a patch that supports building of PostgreSQL with VS 2019.
VS 2019 is going to release on Apr 2nd 2019, it will be good if version 12
supports compiling. The attached for is for review, it may needs some
updates
once the final version is released.

Commit d9dd406fe281d22d5238d3c26a7182543c711e74 has reduced the
minimum visual studio support to 2013 to support C99 standards,
because of this
reason, the current attached patch cannot be backpatched as it is.

I can provide a separate back branches patch later once this patch
comes to a stage of commit. Currently all the supported branches are
possible to compile with VS 2017.

comments?

I have verified that this works with VS2019.

There are a few typos in the comments that need cleaning up.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#9Haribabu Kommi
kommi.haribabu@gmail.com
In reply to: Andrew Dunstan (#8)
1 attachment(s)
Re: MSVC Build support with visual studio 2019

On Wed, Mar 27, 2019 at 3:03 AM Andrew Dunstan <
andrew.dunstan@2ndquadrant.com> wrote:

On 3/20/19 8:36 PM, Haribabu Kommi wrote:

Hi Hackers,

Here I attached a patch that supports building of PostgreSQL with VS

2019.

VS 2019 is going to release on Apr 2nd 2019, it will be good if version

12

supports compiling. The attached for is for review, it may needs some
updates
once the final version is released.

Commit d9dd406fe281d22d5238d3c26a7182543c711e74 has reduced the
minimum visual studio support to 2013 to support C99 standards,
because of this
reason, the current attached patch cannot be backpatched as it is.

I can provide a separate back branches patch later once this patch
comes to a stage of commit. Currently all the supported branches are
possible to compile with VS 2017.

comments?

I have verified that this works with VS2019.

There are a few typos in the comments that need cleaning up.

Thanks for the review.

I corrected the typos in the comments, hopefully I covered everything.
Attached is the updated patch. Once the final VS 2019, I will check the
patch if it needs any more updates.

Regards,
Haribabu Kommi
Fujitsu Australia

Attachments:

0001-Support-building-with-visual-studio-2019_v2.patchapplication/octet-stream; name=0001-Support-building-with-visual-studio-2019_v2.patchDownload
From e3d6417ac3f7c188c74f0d9a6ba172190f7f9a4b Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Wed, 20 Mar 2019 18:35:56 +1100
Subject: [PATCH] Support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 22 ++++++++-------
 src/tools/msvc/MSBuildProject.pm  | 25 +++++++++++++++++
 src/tools/msvc/README             | 10 +++----
 src/tools/msvc/Solution.pm        | 28 +++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 45 ++++++++++++++++++++++++-------
 5 files changed, 106 insertions(+), 24 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index 22a2ffd55e..cc5c9e81da 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2013 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2013 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -69,24 +69,24 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 8.1a to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 8.1a to 10 or
   <productname>Visual Studio 2013</productname> and above. Compilation
   is supported down to <productname>Windows 7</productname> and
   <productname>Windows Server 2008 R2 SP1</productname> when building with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname>.
+  <productname>Visual Studio 2019</productname>.
    <!--
        For 2013 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2013-sysrequirements-vs
@@ -94,6 +94,8 @@
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2015-sysrequirements-vs
        For 2017 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2017-system-requirements-vs
+       For 2019 requirements:
+       https://docs.microsoft.com/en-us/visualstudio/releases/2019/system-requirements
    -->
  </para>
 
@@ -166,7 +168,7 @@ $ENV{MSBFLAGS}="/m";
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></ulink>.
      </para>
      <para>
@@ -175,7 +177,7 @@ $ENV{MSBFLAGS}="/m";
       If you install a <productname>Windows SDK</productname>
       including the <application>Visual C++ Compilers</application>,
       you don't need <productname>Visual Studio</productname> to build.
-      Note that as of Version 8.0a the Windows SDK no longer ships with a
+      Note that as of Version 8.1a the Windows SDK no longer ships with a
       complete command-line build environment.
      </para></listitem>
     </varlistentry>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 149213378c..ca965bdf1a 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -467,4 +467,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(MSBuildProject);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 4ab81d3402..45d71541fc 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2013 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2013 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -89,10 +89,10 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 (Mkvcbuild.pm) which creates the Visual Studio project and solution files.
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2013Project or VC2015Project or VC2017Project from
-MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing
+the corresponding Project interface (VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild) is
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 2ea224d770..ee999c0990 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -871,6 +871,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.32.32432';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 1a94cd866e..b04aff6ea3 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -39,15 +39,28 @@ sub CreateSolution
 		return new VS2015Solution(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -70,15 +83,28 @@ sub CreateProject
 		return new VC2015Project(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -106,18 +132,19 @@ sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
 
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual stuido that is suppored has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
 		  "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
 		return '14.00';
 	}
-	elsif ($major < 6)
+	elsif ($major < 12)
 	{
 		croak
-		  "Unable to determine Visual Studio version: Visual Studio versions before 6.0 aren't supported.";
+		  "Unable to determine Visual Studio version: Visual Studio versions before 12.0 aren't supported.";
 	}
+
 	return "$major.$minor";
 }
 
-- 
2.20.1.windows.1

#10Haribabu Kommi
kommi.haribabu@gmail.com
In reply to: Haribabu Kommi (#9)
4 attachment(s)
Re: MSVC Build support with visual studio 2019

On Wed, Mar 27, 2019 at 11:42 AM Haribabu Kommi <kommi.haribabu@gmail.com>
wrote:

On Wed, Mar 27, 2019 at 3:03 AM Andrew Dunstan <
andrew.dunstan@2ndquadrant.com> wrote:

On 3/20/19 8:36 PM, Haribabu Kommi wrote:

Hi Hackers,

Here I attached a patch that supports building of PostgreSQL with VS

2019.

VS 2019 is going to release on Apr 2nd 2019, it will be good if version

12

supports compiling. The attached for is for review, it may needs some
updates
once the final version is released.

Commit d9dd406fe281d22d5238d3c26a7182543c711e74 has reduced the
minimum visual studio support to 2013 to support C99 standards,
because of this
reason, the current attached patch cannot be backpatched as it is.

I can provide a separate back branches patch later once this patch
comes to a stage of commit. Currently all the supported branches are
possible to compile with VS 2017.

comments?

I have verified that this works with VS2019.

There are a few typos in the comments that need cleaning up.

Thanks for the review.

I corrected the typos in the comments, hopefully I covered everything.
Attached is the updated patch. Once the final VS 2019, I will check the
patch if it needs any more updates.

Visual Studio 2019 is officially released. There is no major change in the
patch, except some small comments update.

Also attached patches for the back branches also.

Regards,
Haribabu Kommi
Fujitsu Australia

Attachments:

0001-Support-building-with-visual-studio-2019_v11.patchapplication/x-patch; name=0001-Support-building-with-visual-studio-2019_v11.patchDownload
From 6b21a229400bae51b225dd96d68249d2a61d9ac2 Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Fri, 5 Apr 2019 10:15:57 +1100
Subject: [PATCH] support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 21 ++++++++--------
 src/tools/msvc/MSBuildProject.pm  | 25 +++++++++++++++++++
 src/tools/msvc/README             | 12 +++++-----
 src/tools/msvc/Solution.pm        | 28 ++++++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 40 +++++++++++++++++++++++++------
 5 files changed, 103 insertions(+), 23 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index ac00ac8232..efa9f5dbc2 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2005 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2005 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -69,19 +69,19 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2005</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 6.0 to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 6.0a to 10 or
   <productname>Visual Studio 2008</productname> and above. Compilation
   is supported down to <productname>Windows XP</productname> and
   <productname>Windows Server 2003</productname> when building with
@@ -89,8 +89,9 @@
   <productname>Visual Studio 2013</productname>. Building with
   <productname>Visual Studio 2015</productname> is supported down to
   <productname>Windows Vista</productname> and <productname>Windows Server 2008</productname>.
-   Building with <productname>Visual Studio 2017</productname> is supported
-   down to <productname>Windows 7 SP1</productname> and <productname>Windows Server 2008 R2 SP1</productname>.
+  Building with <productname>Visual Studio 2017</productname> and <productname>Visual Studio 2019</productname>
+  are supported down to <productname>Windows 7 SP1</productname> and
+  <productname>Windows Server 2008 R2 SP1</productname>.
  </para>
 
  <para>
@@ -162,7 +163,7 @@ $ENV{MSBFLAGS}="/m";
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></ulink>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 47252533a1..3edb11b9b5 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -535,4 +535,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(VC2012Project);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 48082cab90..0a41dbff8c 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2005 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -93,11 +93,11 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2005Solution,
 a VS2008Solution, a VS2010Solution or a VS2012Solution or a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
-VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
-from MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing the
+corresponding Project interface (VC2005Project or VC2008Project from VCBuildProject.pm
+or VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild or vcbuild)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 78db247b29..a253b5ea5e 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -946,6 +946,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.32.32432';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 92a4fb6841..d65fdd1259 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -56,15 +56,28 @@ sub CreateSolution
 		return new VS2015Solution(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -103,15 +116,28 @@ sub CreateProject
 		return new VC2015Project(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -139,7 +165,7 @@ sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
 
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual stuido that is suppored has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
-- 
2.20.1.windows.1

0001-support-building-with-visual-studio-2019_v10_to_v9.6.patchapplication/x-patch; name=0001-support-building-with-visual-studio-2019_v10_to_v9.6.patchDownload
From 0bb99859bd374e00577d3db1801cb6f634769ec6 Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Fri, 5 Apr 2019 11:08:43 +1100
Subject: [PATCH] support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 21 ++++++++-------
 src/tools/msvc/MSBuildProject.pm  | 25 ++++++++++++++++++
 src/tools/msvc/README             | 12 ++++-----
 src/tools/msvc/Solution.pm        | 28 ++++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 44 ++++++++++++++++++++++++++-----
 5 files changed, 107 insertions(+), 23 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index f70fee407b..7d2552563a 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2005 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2005 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -69,19 +69,19 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2005</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 6.0 to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 6.0a to 10 or
   <productname>Visual Studio 2008</productname> and above. Compilation
   is supported down to <productname>Windows XP</productname> and
   <productname>Windows Server 2003</> when building with
@@ -89,8 +89,9 @@
   <productname>Visual Studio 2013</productname>. Building with
   <productname>Visual Studio 2015</productname> is supported down to
   <productname>Windows Vista</> and <productname>Windows Server 2008</>.
-   Building with <productname>Visual Studio 2017</productname> is supported
-   down to <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
+   Building with <productname>Visual Studio 2017</productname> and
+   <prodcutname>Visual Studio 2019</prodcutname> are supported down to
+   <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
  </para>
 
  <para>
@@ -162,7 +163,7 @@ $ENV{MSBFLAGS}="/m";
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 9ddccc7c55..d0f2fe7779 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -508,4 +508,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(VC2012Project);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 48082cab90..0a41dbff8c 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2005 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -93,11 +93,11 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2005Solution,
 a VS2008Solution, a VS2010Solution or a VS2012Solution or a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
-VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
-from MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing the
+corresponding Project interface (VC2005Project or VC2008Project from VCBuildProject.pm
+or VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild or vcbuild)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 17f86c5ee8..54bd4b0098 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -881,6 +881,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.32.32432';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 2f3480a1f6..6a75d874b3 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -53,14 +53,29 @@ sub CreateSolution
 	{
 		return new VS2015Solution(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -98,14 +113,29 @@ sub CreateProject
 	{
 		return new VC2015Project(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -132,7 +162,7 @@ sub DetermineVisualStudioVersion
 sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual stuido that is suppored has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
-- 
2.20.1.windows.1

0001-Support-building-with-visual-studio-2019.patchapplication/x-patch; name=0001-Support-building-with-visual-studio-2019.patchDownload
From e360bc8ee3d392441ec3765347f6beda3bfb9c3b Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Wed, 20 Mar 2019 18:35:56 +1100
Subject: [PATCH] Support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 20 +++++++-------
 src/tools/msvc/MSBuildProject.pm  | 25 ++++++++++++++++++
 src/tools/msvc/README             | 10 +++----
 src/tools/msvc/Solution.pm        | 28 ++++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 44 ++++++++++++++++++++++++-------
 5 files changed, 104 insertions(+), 23 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index 22a2ffd55e..0bbb314c3b 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2013 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2013 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -69,24 +69,24 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 8.1a to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 8.1a to 10 or
   <productname>Visual Studio 2013</productname> and above. Compilation
   is supported down to <productname>Windows 7</productname> and
   <productname>Windows Server 2008 R2 SP1</productname> when building with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname>.
+  <productname>Visual Studio 2019</productname>.
    <!--
        For 2013 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2013-sysrequirements-vs
@@ -94,6 +94,8 @@
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2015-sysrequirements-vs
        For 2017 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2017-system-requirements-vs
+       For 2019 requirements:
+       https://docs.microsoft.com/en-us/visualstudio/releases/2019/system-requirements
    -->
  </para>
 
@@ -166,7 +168,7 @@ $ENV{MSBFLAGS}="/m";
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></ulink>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 149213378c..ca965bdf1a 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -467,4 +467,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(MSBuildProject);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 4ab81d3402..45d71541fc 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2013 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2013 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -89,10 +89,10 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 (Mkvcbuild.pm) which creates the Visual Studio project and solution files.
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2013Project or VC2015Project or VC2017Project from
-MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing
+the corresponding Project interface (VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild) is
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 2ea224d770..ee999c0990 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -871,6 +871,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.32.32432';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 1a94cd866e..c5c0b11004 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -39,15 +39,28 @@ sub CreateSolution
 		return new VS2015Solution(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -70,15 +83,28 @@ sub CreateProject
 		return new VC2015Project(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -106,17 +132,17 @@ sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
 
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual stuido that is suppored has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
 		  "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
 		return '14.00';
 	}
-	elsif ($major < 6)
+	elsif ($major < 12)
 	{
 		croak
-		  "Unable to determine Visual Studio version: Visual Studio versions before 6.0 aren't supported.";
+		  "Unable to determine Visual Studio version: Visual Studio versions before 12.0 aren't supported.";
 	}
 	return "$major.$minor";
 }
-- 
2.20.1.windows.1

0001-support-building-with-visual-studio-2019_v9.4.patchapplication/x-patch; name=0001-support-building-with-visual-studio-2019_v9.4.patchDownload
From 5d524cdebf21d7d35d561171784acf689ab86a0f Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Fri, 5 Apr 2019 11:24:58 +1100
Subject: [PATCH] support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 21 ++++++++-------
 src/tools/msvc/MSBuildProject.pm  | 25 ++++++++++++++++++
 src/tools/msvc/README             | 12 ++++-----
 src/tools/msvc/Solution.pm        | 28 ++++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 44 ++++++++++++++++++++++++++-----
 5 files changed, 107 insertions(+), 23 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index fca65ec41f..ef89e4bb34 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2005 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2005 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -77,19 +77,19 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL buils are possible with
   <productname>Visual Studio 2005</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 6.0 to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 6.0a to 10 or
   <productname>Visual Studio 2008</productname> and above. Compilation
   is supported down to <productname>Windows XP</productname> and
   <productname>Windows Server 2003</> when building with
@@ -97,8 +97,9 @@
   <productname>Visual Studio 2013</productname>. Building with
   <productname>Visual Studio 2015</productname> is supported down to
   <productname>Windows Vista</> and <productname>Windows Server 2008</>.
-   Building with <productname>Visual Studio 2017</productname> is supported
-   down to <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
+   Building with <productname>Visual Studio 2017</productname> and
+   <prodcutname>Visual Studio 2019</prodcutname> are supported down to
+   <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
  </para>
 
  <para>
@@ -162,7 +163,7 @@ $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 2c4ae7b278..158763d9b2 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -508,4 +508,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(VC2012Project);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 48082cab90..0a41dbff8c 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2005 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -93,11 +93,11 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2005Solution,
 a VS2008Solution, a VS2010Solution or a VS2012Solution or a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
-VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
-from MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing the
+corresponding Project interface (VC2005Project or VC2008Project from VCBuildProject.pm
+or VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild or vcbuild)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index d1a791c5ad..12ac1ebc99 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -833,6 +833,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.32.32432';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index cb1e55e999..7c21962beb 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -53,14 +53,29 @@ sub CreateSolution
 	{
 		return new VS2015Solution(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -98,14 +113,29 @@ sub CreateProject
 	{
 		return new VC2015Project(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -143,7 +173,7 @@ sub DetermineVisualStudioVersion
 sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual stuido that is suppored has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
-- 
2.20.1.windows.1

#11Juanjo Santamaria Flecha
juanjo.santamaria@gmail.com
In reply to: Haribabu Kommi (#10)
Re: MSVC Build support with visual studio 2019

I have gone through path '0001-Support-building-with-visual-studio-2019.patch' only, but I am sure some comments will also apply to back branches.

1. The VisualStudioVersion value looks odd:

+ $self->{VisualStudioVersion} = '16.0.32.32432';

Are you using a pre-release version [1]https://docs.microsoft.com/en-us/visualstudio/releases/2019/history#release-dates-and-build-numbers?

2. There is a typo: s/stuido/studio/:

+ # The major visual stuido that is suppored has nmake version >= 14.20 and < 15.

There is something in the current code that I think should be also updated. The code for _GetVisualStudioVersion contains:

if ($major > 14)
{
carp
"The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
return '14.00';
}

Shouldn't the returned value be '14.20' for Visual Studio 2019?

Regards,

Juan José Santamaría Flecha

[1]: https://docs.microsoft.com/en-us/visualstudio/releases/2019/history#release-dates-and-build-numbers

#12Haribabu Kommi
kommi.haribabu@gmail.com
In reply to: Juanjo Santamaria Flecha (#11)
4 attachment(s)
Re: MSVC Build support with visual studio 2019

On Wed, May 22, 2019 at 7:36 AM Juanjo Santamaria Flecha <
juanjo.santamaria@gmail.com> wrote:

I have gone through path
'0001-Support-building-with-visual-studio-2019.patch' only, but I am sure
some comments will also apply to back branches.

Thanks for the review.

1. The VisualStudioVersion value looks odd:

+ $self->{VisualStudioVersion} = '16.0.32.32432';

Are you using a pre-release version [1]?

I first developed this patch on the preview version.
I updated it to version 16.0.28729.10.

2. There is a typo: s/stuido/studio/:

+ # The major visual stuido that is suppored has nmake version >=
14.20 and < 15.

There is something in the current code that I think should be also
updated. The code for _GetVisualStudioVersion contains:

if ($major > 14)
{
carp
"The determined version of Visual Studio is newer than the latest
supported version. Returning the latest supported version instead.";
return '14.00';
}

Shouldn't the returned value be '14.20' for Visual Studio 2019?

Yes, that will be good to return Visual Studio 2019, updated.

Updated patches are attached for all branches.

Regards,
Haribabu Kommi
Fujitsu Australia

Attachments:

0001-Support-building-with-visual-studio-2019_HEAD.patchapplication/octet-stream; name=0001-Support-building-with-visual-studio-2019_HEAD.patchDownload
From b44d78ff64b9ba2dd23b0b978e29e9ece9dc843c Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Wed, 20 Mar 2019 18:35:56 +1100
Subject: [PATCH] Support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 20 ++++++++------
 src/tools/msvc/MSBuildProject.pm  | 25 +++++++++++++++++
 src/tools/msvc/README             | 10 +++----
 src/tools/msvc/Solution.pm        | 28 +++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 46 ++++++++++++++++++++++++-------
 5 files changed, 105 insertions(+), 24 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index 22a2ffd55e..0bbb314c3b 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2013 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2013 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -69,24 +69,24 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 8.1a to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 8.1a to 10 or
   <productname>Visual Studio 2013</productname> and above. Compilation
   is supported down to <productname>Windows 7</productname> and
   <productname>Windows Server 2008 R2 SP1</productname> when building with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname>.
+  <productname>Visual Studio 2019</productname>.
    <!--
        For 2013 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2013-sysrequirements-vs
@@ -94,6 +94,8 @@
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2015-sysrequirements-vs
        For 2017 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2017-system-requirements-vs
+       For 2019 requirements:
+       https://docs.microsoft.com/en-us/visualstudio/releases/2019/system-requirements
    -->
  </para>
 
@@ -166,7 +168,7 @@ $ENV{MSBFLAGS}="/m";
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></ulink>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 149213378c..ca965bdf1a 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -467,4 +467,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(MSBuildProject);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 4ab81d3402..45d71541fc 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2013 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2013 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -89,10 +89,10 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 (Mkvcbuild.pm) which creates the Visual Studio project and solution files.
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2013Project or VC2015Project or VC2017Project from
-MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing
+the corresponding Project interface (VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild) is
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 33ba15c15e..05ede8930a 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -882,6 +882,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.28729.10';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 1a94cd866e..8b6ddd962f 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -39,15 +39,28 @@ sub CreateSolution
 		return new VS2015Solution(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -70,15 +83,28 @@ sub CreateProject
 		return new VC2015Project(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -106,17 +132,17 @@ sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
 
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual stuido that is suppored has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
 		  "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
-		return '14.00';
+		return '14.20';
 	}
-	elsif ($major < 6)
+	elsif ($major < 12)
 	{
 		croak
-		  "Unable to determine Visual Studio version: Visual Studio versions before 6.0 aren't supported.";
+		  "Unable to determine Visual Studio version: Visual Studio versions before 12.0 aren't supported.";
 	}
 	return "$major.$minor";
 }
-- 
2.20.1.windows.1

0001-support-building-with-visual-studio-2019_v11.patchapplication/octet-stream; name=0001-support-building-with-visual-studio-2019_v11.patchDownload
From 450e7f31862cbeddfe0bca7fe649686f6ed979fb Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Fri, 5 Apr 2019 10:15:57 +1100
Subject: [PATCH] support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 21 ++++++++--------
 src/tools/msvc/MSBuildProject.pm  | 25 ++++++++++++++++++
 src/tools/msvc/README             | 12 ++++-----
 src/tools/msvc/Solution.pm        | 28 +++++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 42 +++++++++++++++++++++++++------
 5 files changed, 104 insertions(+), 24 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index ac00ac8232..efa9f5dbc2 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2005 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2005 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -69,19 +69,19 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2005</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 6.0 to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 6.0a to 10 or
   <productname>Visual Studio 2008</productname> and above. Compilation
   is supported down to <productname>Windows XP</productname> and
   <productname>Windows Server 2003</productname> when building with
@@ -89,8 +89,9 @@
   <productname>Visual Studio 2013</productname>. Building with
   <productname>Visual Studio 2015</productname> is supported down to
   <productname>Windows Vista</productname> and <productname>Windows Server 2008</productname>.
-   Building with <productname>Visual Studio 2017</productname> is supported
-   down to <productname>Windows 7 SP1</productname> and <productname>Windows Server 2008 R2 SP1</productname>.
+  Building with <productname>Visual Studio 2017</productname> and <productname>Visual Studio 2019</productname>
+  are supported down to <productname>Windows 7 SP1</productname> and
+  <productname>Windows Server 2008 R2 SP1</productname>.
  </para>
 
  <para>
@@ -162,7 +163,7 @@ $ENV{MSBFLAGS}="/m";
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></ulink>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 47252533a1..3edb11b9b5 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -535,4 +535,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(VC2012Project);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 48082cab90..0a41dbff8c 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2005 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -93,11 +93,11 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2005Solution,
 a VS2008Solution, a VS2010Solution or a VS2012Solution or a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
-VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
-from MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing the
+corresponding Project interface (VC2005Project or VC2008Project from VCBuildProject.pm
+or VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild or vcbuild)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 78db247b29..b2c79ec831 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -946,6 +946,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.28729.10';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 92a4fb6841..69a3786324 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -56,15 +56,28 @@ sub CreateSolution
 		return new VS2015Solution(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -103,15 +116,28 @@ sub CreateProject
 		return new VC2015Project(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -139,12 +165,12 @@ sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
 
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual stuido that is suppored has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
 		  "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
-		return '14.00';
+		return '14.20';
 	}
 	elsif ($major < 6)
 	{
-- 
2.20.1.windows.1

0001-support-building-with-visual-studio-2019_v9.4.patchapplication/octet-stream; name=0001-support-building-with-visual-studio-2019_v9.4.patchDownload
From cf1b743284b63f6ccda87762dd56e8189a73bd2a Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Fri, 5 Apr 2019 11:24:58 +1100
Subject: [PATCH] support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 21 +++++++-------
 src/tools/msvc/MSBuildProject.pm  | 25 +++++++++++++++++
 src/tools/msvc/README             | 12 ++++----
 src/tools/msvc/Solution.pm        | 28 +++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 46 +++++++++++++++++++++++++------
 5 files changed, 108 insertions(+), 24 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index fca65ec41f..ef89e4bb34 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2005 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2005 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -77,19 +77,19 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL buils are possible with
   <productname>Visual Studio 2005</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 6.0 to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 6.0a to 10 or
   <productname>Visual Studio 2008</productname> and above. Compilation
   is supported down to <productname>Windows XP</productname> and
   <productname>Windows Server 2003</> when building with
@@ -97,8 +97,9 @@
   <productname>Visual Studio 2013</productname>. Building with
   <productname>Visual Studio 2015</productname> is supported down to
   <productname>Windows Vista</> and <productname>Windows Server 2008</>.
-   Building with <productname>Visual Studio 2017</productname> is supported
-   down to <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
+   Building with <productname>Visual Studio 2017</productname> and
+   <prodcutname>Visual Studio 2019</prodcutname> are supported down to
+   <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
  </para>
 
  <para>
@@ -162,7 +163,7 @@ $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 2c4ae7b278..158763d9b2 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -508,4 +508,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(VC2012Project);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 48082cab90..0a41dbff8c 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2005 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -93,11 +93,11 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2005Solution,
 a VS2008Solution, a VS2010Solution or a VS2012Solution or a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
-VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
-from MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing the
+corresponding Project interface (VC2005Project or VC2008Project from VCBuildProject.pm
+or VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild or vcbuild)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index d1a791c5ad..d64bf0e72a 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -833,6 +833,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.28729.10';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index cb1e55e999..d7129ac2dc 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -53,14 +53,29 @@ sub CreateSolution
 	{
 		return new VS2015Solution(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -98,14 +113,29 @@ sub CreateProject
 	{
 		return new VC2015Project(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -143,12 +173,12 @@ sub DetermineVisualStudioVersion
 sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual stuido that is suppored has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
 "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
-		return '14.00';
+		return '14.20';
 	}
 	elsif ($major < 6)
 	{
-- 
2.20.1.windows.1

0001-support-building-with-visual-studio-2019_v10_to_v9.5.patchapplication/octet-stream; name=0001-support-building-with-visual-studio-2019_v10_to_v9.5.patchDownload
From 8dee021f1a75f5e014461b06cedd29e7561b39db Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Fri, 5 Apr 2019 11:08:43 +1100
Subject: [PATCH] support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 21 +++++++-------
 src/tools/msvc/MSBuildProject.pm  | 25 +++++++++++++++++
 src/tools/msvc/README             | 12 ++++----
 src/tools/msvc/Solution.pm        | 28 +++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 46 +++++++++++++++++++++++++------
 5 files changed, 108 insertions(+), 24 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index 4e5681cf46..1efaf224e5 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2005 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2005 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -77,19 +77,19 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2005</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 6.0 to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 6.0a to 10 or
   <productname>Visual Studio 2008</productname> and above. Compilation
   is supported down to <productname>Windows XP</productname> and
   <productname>Windows Server 2003</> when building with
@@ -97,8 +97,9 @@
   <productname>Visual Studio 2013</productname>. Building with
   <productname>Visual Studio 2015</productname> is supported down to
   <productname>Windows Vista</> and <productname>Windows Server 2008</>.
-   Building with <productname>Visual Studio 2017</productname> is supported
-   down to <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
+   Building with <productname>Visual Studio 2017</productname> and
+   <prodcutname>Visual Studio 2019</prodcutname> are supported down to
+   <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
  </para>
 
  <para>
@@ -162,7 +163,7 @@ $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 9ddccc7c55..d0f2fe7779 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -508,4 +508,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(VC2012Project);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 48082cab90..0a41dbff8c 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2005 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -93,11 +93,11 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2005Solution,
 a VS2008Solution, a VS2010Solution or a VS2012Solution or a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
-VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
-from MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing the
+corresponding Project interface (VC2005Project or VC2008Project from VCBuildProject.pm
+or VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild or vcbuild)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 78dfadc2b3..a8e6bf5c8e 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -857,6 +857,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.28729.10';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 2f3480a1f6..4e682d1251 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -53,14 +53,29 @@ sub CreateSolution
 	{
 		return new VS2015Solution(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -98,14 +113,29 @@ sub CreateProject
 	{
 		return new VC2015Project(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -132,12 +162,12 @@ sub DetermineVisualStudioVersion
 sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual stuido that is suppored has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
 "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
-		return '14.00';
+		return '14.20';
 	}
 	elsif ($major < 6)
 	{
-- 
2.20.1.windows.1

#13Juan José Santamaría Flecha
juanjo.santamaria@gmail.com
In reply to: Haribabu Kommi (#12)
Re: MSVC Build support with visual studio 2019

On Thu, May 23, 2019 at 3:44 AM Haribabu Kommi <kommi.haribabu@gmail.com>
wrote:

Updated patches are attached for all branches.

I have gone through all patches and there are a couple of typos:

1. s/prodcutname/productname/

    1.1 In file: 0001-support-building-with-visual-studio-2019_v9.4.patch
@@ -97,8 +97,9 @@
   <productname>Visual Studio 2013</productname>. Building with
   <productname>Visual Studio 2015</productname> is supported down to
   <productname>Windows Vista</> and <productname>Windows Server 2008</>.
-   Building with <productname>Visual Studio 2017</productname> is supported
-   down to <productname>Windows 7 SP1</> and <productname>Windows Server
2008 R2 SP1</>.
+   Building with <productname>Visual Studio 2017</productname> and
+   <prodcutname>Visual Studio 2019</prodcutname> are supported down to
    1.2 In file:
0001-support-building-with-visual-studio-2019_v10_to_v9.5.patch
@@ -97,8 +97,9 @@
   <productname>Visual Studio 2013</productname>. Building with
   <productname>Visual Studio 2015</productname> is supported down to
   <productname>Windows Vista</> and <productname>Windows Server 2008</>.
-   Building with <productname>Visual Studio 2017</productname> is supported
-   down to <productname>Windows 7 SP1</> and <productname>Windows Server
2008 R2 SP1</>.
+   Building with <productname>Visual Studio 2017</productname> and
+   <prodcutname>Visual Studio 2019</prodcutname> are supported down to

2. s/stuido/studio/

     2.1 In file: 0001-support-building-with-visual-studio-2019_v9.4.patch
 @@ -143,12 +173,12 @@ sub DetermineVisualStudioVersion
 sub _GetVisualStudioVersion
 {
  my ($major, $minor) = @_;
- # visual 2017 hasn't changed the nmake version to 15, so still using the
older version for comparison.
+ # The major visual stuido that is suppored has nmake version >= 14.20 and
< 15.
     2.2 In file:
0001-support-building-with-visual-studio-2019_v10_to_v9.5.patch
@@ -132,12 +162,12 @@ sub DetermineVisualStudioVersion
 sub _GetVisualStudioVersion
 {
  my ($major, $minor) = @_;
- # visual 2017 hasn't changed the nmake version to 15, so still using the
older version for comparison.
+ # The major visual stuido that is suppored has nmake version >= 14.20 and
< 15.

2.3 In file: 0001-support-building-with-visual-studio-2019_v11.patch
@@ -139,12 +165,12 @@ sub _GetVisualStudioVersion
{
my ($major, $minor) = @_;

- # visual 2017 hasn't changed the nmake version to 15, so still using the
older version for comparison.
+ # The major visual stuido that is suppored has nmake version >= 14.20 and
< 15.

2.4 In file: 0001-Support-building-with-visual-studio-2019_HEAD.patch
@@ -106,17 +132,17 @@ sub _GetVisualStudioVersion
{
my ($major, $minor) = @_;

- # visual 2017 hasn't changed the nmake version to 15, so still using the
older version for comparison.
+ # The major visual stuido that is suppored has nmake version >= 14.20 and
< 15.

Other than that, since this is affects comments and docs, I have already
tested that the patches build and pass tests on all the intended versions.

Regards,

Juan José Santamaría Flecha

#14Haribabu Kommi
kommi.haribabu@gmail.com
In reply to: Juan José Santamaría Flecha (#13)
4 attachment(s)
Re: MSVC Build support with visual studio 2019

On Mon, May 27, 2019 at 8:14 PM Juan José Santamaría Flecha <
juanjo.santamaria@gmail.com> wrote:

On Thu, May 23, 2019 at 3:44 AM Haribabu Kommi <kommi.haribabu@gmail.com>
wrote:

Updated patches are attached for all branches.

I have gone through all patches and there are a couple of typos:

Thanks for the review.

1. s/prodcutname/productname/

1.1 In file: 0001-support-building-with-visual-studio-2019_v9.4.patch
@@ -97,8 +97,9 @@
<productname>Visual Studio 2013</productname>. Building with
<productname>Visual Studio 2015</productname> is supported down to
<productname>Windows Vista</> and <productname>Windows Server 2008</>.
-   Building with <productname>Visual Studio 2017</productname> is
supported
-   down to <productname>Windows 7 SP1</> and <productname>Windows Server
2008 R2 SP1</>.
+   Building with <productname>Visual Studio 2017</productname> and
+   <prodcutname>Visual Studio 2019</prodcutname> are supported down to
1.2 In file:
0001-support-building-with-visual-studio-2019_v10_to_v9.5.patch
@@ -97,8 +97,9 @@
<productname>Visual Studio 2013</productname>. Building with
<productname>Visual Studio 2015</productname> is supported down to
<productname>Windows Vista</> and <productname>Windows Server 2008</>.
-   Building with <productname>Visual Studio 2017</productname> is
supported
-   down to <productname>Windows 7 SP1</> and <productname>Windows Server
2008 R2 SP1</>.
+   Building with <productname>Visual Studio 2017</productname> and
+   <prodcutname>Visual Studio 2019</prodcutname> are supported down to

Corrected.

2. s/stuido/studio/

2.1 In file: 0001-support-building-with-visual-studio-2019_v9.4.patch
@@ -143,12 +173,12 @@ sub DetermineVisualStudioVersion
sub _GetVisualStudioVersion
{
my ($major, $minor) = @_;
- # visual 2017 hasn't changed the nmake version to 15, so still using
the older version for comparison.
+ # The major visual stuido that is suppored has nmake version >= 14.20
and < 15.
2.2 In file:
0001-support-building-with-visual-studio-2019_v10_to_v9.5.patch
@@ -132,12 +162,12 @@ sub DetermineVisualStudioVersion
sub _GetVisualStudioVersion
{
my ($major, $minor) = @_;
- # visual 2017 hasn't changed the nmake version to 15, so still using
the older version for comparison.
+ # The major visual stuido that is suppored has nmake version >= 14.20
and < 15.

2.3 In file: 0001-support-building-with-visual-studio-2019_v11.patch
@@ -139,12 +165,12 @@ sub _GetVisualStudioVersion
{
my ($major, $minor) = @_;

- # visual 2017 hasn't changed the nmake version to 15, so still using
the older version for comparison.
+ # The major visual stuido that is suppored has nmake version >= 14.20
and < 15.

2.4 In file: 0001-Support-building-with-visual-studio-2019_HEAD.patch
@@ -106,17 +132,17 @@ sub _GetVisualStudioVersion
{
my ($major, $minor) = @_;

- # visual 2017 hasn't changed the nmake version to 15, so still using
the older version for comparison.
+ # The major visual stuido that is suppored has nmake version >= 14.20
and < 15.

Corrected. And also 'supported' spelling is also wrong.

Updated patches are attached.

Regards,
Haribabu Kommi
Fujitsu Australia

Attachments:

0001-support-building-with-visual-studio-2019_v11_v3.patchapplication/octet-stream; name=0001-support-building-with-visual-studio-2019_v11_v3.patchDownload
From 450e7f31862cbeddfe0bca7fe649686f6ed979fb Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Fri, 5 Apr 2019 10:15:57 +1100
Subject: [PATCH] support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 21 ++++++++--------
 src/tools/msvc/MSBuildProject.pm  | 25 ++++++++++++++++++
 src/tools/msvc/README             | 12 ++++-----
 src/tools/msvc/Solution.pm        | 28 +++++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 42 +++++++++++++++++++++++++------
 5 files changed, 104 insertions(+), 24 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index ac00ac8232..efa9f5dbc2 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2005 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2005 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -69,19 +69,19 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2005</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 6.0 to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 6.0a to 10 or
   <productname>Visual Studio 2008</productname> and above. Compilation
   is supported down to <productname>Windows XP</productname> and
   <productname>Windows Server 2003</productname> when building with
@@ -89,8 +89,9 @@
   <productname>Visual Studio 2013</productname>. Building with
   <productname>Visual Studio 2015</productname> is supported down to
   <productname>Windows Vista</productname> and <productname>Windows Server 2008</productname>.
-   Building with <productname>Visual Studio 2017</productname> is supported
-   down to <productname>Windows 7 SP1</productname> and <productname>Windows Server 2008 R2 SP1</productname>.
+  Building with <productname>Visual Studio 2017</productname> and <productname>Visual Studio 2019</productname>
+  are supported down to <productname>Windows 7 SP1</productname> and
+  <productname>Windows Server 2008 R2 SP1</productname>.
  </para>
 
  <para>
@@ -162,7 +163,7 @@ $ENV{MSBFLAGS}="/m";
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></ulink>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 47252533a1..3edb11b9b5 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -535,4 +535,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(VC2012Project);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 48082cab90..0a41dbff8c 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2005 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -93,11 +93,11 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2005Solution,
 a VS2008Solution, a VS2010Solution or a VS2012Solution or a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
-VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
-from MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing the
+corresponding Project interface (VC2005Project or VC2008Project from VCBuildProject.pm
+or VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild or vcbuild)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 78db247b29..b2c79ec831 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -946,6 +946,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.28729.10';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 92a4fb6841..69a3786324 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -56,15 +56,28 @@ sub CreateSolution
 		return new VS2015Solution(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -103,15 +116,28 @@ sub CreateProject
 		return new VC2015Project(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -139,12 +165,12 @@ sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
 
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual studio that is supported has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
 		  "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
-		return '14.00';
+		return '14.20';
 	}
 	elsif ($major < 6)
 	{
-- 
2.20.1.windows.1

0001-support-building-with-visual-studio-2019_v10_to_v9.6_v3.patchapplication/octet-stream; name=0001-support-building-with-visual-studio-2019_v10_to_v9.6_v3.patchDownload
From 8dee021f1a75f5e014461b06cedd29e7561b39db Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Fri, 5 Apr 2019 11:08:43 +1100
Subject: [PATCH] support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 21 +++++++-------
 src/tools/msvc/MSBuildProject.pm  | 25 +++++++++++++++++
 src/tools/msvc/README             | 12 ++++----
 src/tools/msvc/Solution.pm        | 28 +++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 46 +++++++++++++++++++++++++------
 5 files changed, 108 insertions(+), 24 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index 4e5681cf46..1efaf224e5 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2005 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2005 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -77,19 +77,19 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2005</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 6.0 to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 6.0a to 10 or
   <productname>Visual Studio 2008</productname> and above. Compilation
   is supported down to <productname>Windows XP</productname> and
   <productname>Windows Server 2003</> when building with
@@ -97,8 +97,9 @@
   <productname>Visual Studio 2013</productname>. Building with
   <productname>Visual Studio 2015</productname> is supported down to
   <productname>Windows Vista</> and <productname>Windows Server 2008</>.
-   Building with <productname>Visual Studio 2017</productname> is supported
-   down to <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
+   Building with <productname>Visual Studio 2017</productname> and
+   <productname>Visual Studio 2019</productname> are supported down to
+   <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
  </para>
 
  <para>
@@ -162,7 +163,7 @@ $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 9ddccc7c55..d0f2fe7779 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -508,4 +508,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(VC2012Project);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 48082cab90..0a41dbff8c 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2005 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -93,11 +93,11 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2005Solution,
 a VS2008Solution, a VS2010Solution or a VS2012Solution or a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
-VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
-from MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing the
+corresponding Project interface (VC2005Project or VC2008Project from VCBuildProject.pm
+or VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild or vcbuild)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 78dfadc2b3..a8e6bf5c8e 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -857,6 +857,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.28729.10';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 2f3480a1f6..4e682d1251 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -53,14 +53,29 @@ sub CreateSolution
 	{
 		return new VS2015Solution(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -98,14 +113,29 @@ sub CreateProject
 	{
 		return new VC2015Project(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -132,12 +162,12 @@ sub DetermineVisualStudioVersion
 sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual studio that is supported has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
 "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
-		return '14.00';
+		return '14.20';
 	}
 	elsif ($major < 6)
 	{
-- 
2.20.1.windows.1

0001-support-building-with-visual-studio-2019_v9.4_v3.patchapplication/octet-stream; name=0001-support-building-with-visual-studio-2019_v9.4_v3.patchDownload
From cf1b743284b63f6ccda87762dd56e8189a73bd2a Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Fri, 5 Apr 2019 11:24:58 +1100
Subject: [PATCH] support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 21 +++++++-------
 src/tools/msvc/MSBuildProject.pm  | 25 +++++++++++++++++
 src/tools/msvc/README             | 12 ++++----
 src/tools/msvc/Solution.pm        | 28 +++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 46 +++++++++++++++++++++++++------
 5 files changed, 108 insertions(+), 24 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index fca65ec41f..ef89e4bb34 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2005 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2005 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -77,19 +77,19 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL buils are possible with
   <productname>Visual Studio 2005</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 6.0 to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 6.0a to 10 or
   <productname>Visual Studio 2008</productname> and above. Compilation
   is supported down to <productname>Windows XP</productname> and
   <productname>Windows Server 2003</> when building with
@@ -97,8 +97,9 @@
   <productname>Visual Studio 2013</productname>. Building with
   <productname>Visual Studio 2015</productname> is supported down to
   <productname>Windows Vista</> and <productname>Windows Server 2008</>.
-   Building with <productname>Visual Studio 2017</productname> is supported
-   down to <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
+   Building with <productname>Visual Studio 2017</productname> and
+   <productname>Visual Studio 2019</productname> are supported down to
+   <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
  </para>
 
  <para>
@@ -162,7 +163,7 @@ $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 2c4ae7b278..158763d9b2 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -508,4 +508,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(VC2012Project);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 48082cab90..0a41dbff8c 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2005 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -93,11 +93,11 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2005Solution,
 a VS2008Solution, a VS2010Solution or a VS2012Solution or a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
-VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
-from MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing the
+corresponding Project interface (VC2005Project or VC2008Project from VCBuildProject.pm
+or VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild or vcbuild)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index d1a791c5ad..d64bf0e72a 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -833,6 +833,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.28729.10';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index cb1e55e999..d7129ac2dc 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -53,14 +53,29 @@ sub CreateSolution
 	{
 		return new VS2015Solution(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -98,14 +113,29 @@ sub CreateProject
 	{
 		return new VC2015Project(@_);
 	}
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
+
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
+		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -143,12 +173,12 @@ sub DetermineVisualStudioVersion
 sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual studio that is supported has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
 "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
-		return '14.00';
+		return '14.20';
 	}
 	elsif ($major < 6)
 	{
-- 
2.20.1.windows.1

0001-Support-building-with-visual-studio-2019_HEAD_v3.patchapplication/octet-stream; name=0001-Support-building-with-visual-studio-2019_HEAD_v3.patchDownload
From b44d78ff64b9ba2dd23b0b978e29e9ece9dc843c Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Wed, 20 Mar 2019 18:35:56 +1100
Subject: [PATCH] Support building with visual studio 2019

---
 doc/src/sgml/install-windows.sgml | 20 ++++++++------
 src/tools/msvc/MSBuildProject.pm  | 25 +++++++++++++++++
 src/tools/msvc/README             | 10 +++----
 src/tools/msvc/Solution.pm        | 28 +++++++++++++++++++
 src/tools/msvc/VSObjectFactory.pm | 46 ++++++++++++++++++++++++-------
 5 files changed, 105 insertions(+), 24 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index 22a2ffd55e..0bbb314c3b 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2013 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2013 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -69,24 +69,24 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 8.1a to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 8.1a to 10 or
   <productname>Visual Studio 2013</productname> and above. Compilation
   is supported down to <productname>Windows 7</productname> and
   <productname>Windows Server 2008 R2 SP1</productname> when building with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname>.
+  <productname>Visual Studio 2019</productname>.
    <!--
        For 2013 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2013-sysrequirements-vs
@@ -94,6 +94,8 @@
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2015-sysrequirements-vs
        For 2017 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2017-system-requirements-vs
+       For 2019 requirements:
+       https://docs.microsoft.com/en-us/visualstudio/releases/2019/system-requirements
    -->
  </para>
 
@@ -166,7 +168,7 @@ $ENV{MSBFLAGS}="/m";
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></ulink>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 149213378c..ca965bdf1a 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -467,4 +467,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(MSBuildProject);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 4ab81d3402..45d71541fc 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2013 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2013 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -89,10 +89,10 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 (Mkvcbuild.pm) which creates the Visual Studio project and solution files.
 It does this by using VSObjectFactory::CreateSolution to create an object
 implementing the Solution interface (this could be either a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2013Project or VC2015Project or VC2017Project from
-MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing
+the corresponding Project interface (VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild) is
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 33ba15c15e..05ede8930a 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -882,6 +882,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.28729.10';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 1a94cd866e..8b6ddd962f 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -39,15 +39,28 @@ sub CreateSolution
 		return new VS2015Solution(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -70,15 +83,28 @@ sub CreateProject
 		return new VC2015Project(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
+	# visual studio 2017 nmake version is greather than 14.10 and less than 14.20.
+	# but the version number is 15.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.10')
+		and ($visualStudioVersion lt '14.20'))
 		or ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# visual studio 2019 nmake version is greather than 14.20 and less than 14.30 (expected).
+	# but the version number is 16.00
+	# so adjust the check to support it.
+	elsif ((($visualStudioVersion ge '14.20')
+		and ($visualStudioVersion lt '14.30'))
+		or ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
+		carp $visualStudioVersion;
 		croak "The requested Visual Studio version is not supported.";
 	}
 }
@@ -106,17 +132,17 @@ sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
 
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+	# The major visual studio that is supported has nmake version >= 14.20 and < 15.
 	if ($major > 14)
 	{
 		carp
 		  "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
-		return '14.00';
+		return '14.20';
 	}
-	elsif ($major < 6)
+	elsif ($major < 12)
 	{
 		croak
-		  "Unable to determine Visual Studio version: Visual Studio versions before 6.0 aren't supported.";
+		  "Unable to determine Visual Studio version: Visual Studio versions before 12.0 aren't supported.";
 	}
 	return "$major.$minor";
 }
-- 
2.20.1.windows.1

#15Juan José Santamaría Flecha
juanjo.santamaria@gmail.com
In reply to: Haribabu Kommi (#14)
Re: MSVC Build support with visual studio 2019

On Wed, May 29, 2019 at 10:30 AM Haribabu Kommi <kommi.haribabu@gmail.com>
wrote:

Updated patches are attached.

All patches apply, build and pass tests. The patch
'0001-support-building-with-visual-studio-2019_v10_to_v9.6_v3.patch'
applies on version 9.5.

Not sure if more review is needed before moving to 'ready for commite'r,
but I have no more comments to make on current patches.

Regards,

Juan José Santamaría Flecha

#16Haribabu Kommi
kommi.haribabu@gmail.com
In reply to: Juan José Santamaría Flecha (#15)
Re: MSVC Build support with visual studio 2019

On Wed, 5 Jun 2019 at 17:22, Juan José Santamaría Flecha <
juanjo.santamaria@gmail.com> wrote:

On Wed, May 29, 2019 at 10:30 AM Haribabu Kommi <kommi.haribabu@gmail.com>
wrote:

Updated patches are attached.

All patches apply, build and pass tests. The patch
'0001-support-building-with-visual-studio-2019_v10_to_v9.6_v3.patch'
applies on version 9.5.

Not sure if more review is needed before moving to 'ready for commite'r,
but I have no more comments to make on current patches.

Thanks for the review. Yes, that patch applies till 9.5, it is my mistake
in naming the patch.

Regards,
Haribabu Kommi

#17Michael Paquier
michael@paquier.xyz
In reply to: Haribabu Kommi (#16)
1 attachment(s)
Re: MSVC Build support with visual studio 2019

On Wed, Jun 26, 2019 at 10:29:05PM +1000, Haribabu Kommi wrote:

Thanks for the review. Yes, that patch applies till 9.5, it is my mistake
in naming the patch.

I have been able to finally set up an environment with VS 2019 (as
usual this stuff needs time, anyway..), and I can confirm that the
patch is able to compile properly.

-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 8.1a to 10.
I would like to understand why this range of requirements is updated.
Is there any reason to do so.  If we change these docs, what does it
mean in terms of versions of Visual Studio supported?
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2013Project or VC2015Project or VC2017Project from
-MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing
+the corresponding Project interface (VC2013Project or VC2015Project or VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
This formulation is weird the more we accumulate new objects, let's
put that in a proper list of elements separated with commas except
for the two last ones which should use "or".

s/greather/greater/.

The patch still has typos, and the format is not satisfying yet, so I
have done a set of fixes as per the attached.

-   elsif ($major < 6)
+   elsif ($major < 12)
    {
        croak
-         "Unable to determine Visual Studio version:
            Visual Studio versions before 6.0 aren't supported.";
+         "Unable to determine Visual Studio version:
	    Visual Studio versions before 12.0 aren't supported.";
Well, this is a separate bug fix, still I don't mind fixing that in
the same patch as we meddle with those code paths now.  Good catch.
-       croak $visualStudioVersion;
+       carp $visualStudioVersion;
Same here.  Just wouldn't it be better to print the version found in
the same message?

+ # The major visual studio that is supported has nmake version >=
14.20 and < 15.
if ($major > 14)
Comment line is too long. It seems to me that the condition here
should be ($major >= 14 && $minor >= 30). That's not completely
correct either as we have a version higher than 14.20 for VS 2019 but
that's better than just using 14.29 or a fake number I guess.

So for now I have the attached which applies to HEAD. The patch is
not indented yet because the conditions in CreateProject() and
CreateSolution() get messed up, but I'll figure out something.

Any comments? I am wondering the update related to the version range
of the standalone SDKs though. No need for backpatched versions yet,
first let's agree about the shape of what we want on HEAD.
--
Michael

Attachments:

msvc-2019-support-v4.patchtext/x-diff; charset=us-asciiDownload
diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index 22a2ffd55e..0bbb314c3b 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -19,10 +19,10 @@
  <para>
   There are several different ways of building PostgreSQL on
   <productname>Windows</productname>. The simplest way to build with
-  Microsoft tools is to install <productname>Visual Studio Express 2017
+  Microsoft tools is to install <productname>Visual Studio Express 2019
   for Windows Desktop</productname> and use the included
   compiler. It is also possible to build with the full
-  <productname>Microsoft Visual C++ 2013 to 2017</productname>.
+  <productname>Microsoft Visual C++ 2013 to 2019</productname>.
   In some cases that requires the installation of the
   <productname>Windows SDK</productname> in addition to the compiler.
  </para>
@@ -69,24 +69,24 @@
   <productname>Visual Studio Express</productname> or some versions of the
   <productname>Microsoft Windows SDK</productname>. If you do not already have a
   <productname>Visual Studio</productname> environment set up, the easiest
-  ways are to use the compilers from <productname>Visual Studio Express 2017
+  ways are to use the compilers from <productname>Visual Studio Express 2019
   for Windows Desktop</productname> or those in the <productname>Windows SDK
-  8.1</productname>, which are both free downloads from Microsoft.
+  10</productname>, which are both free downloads from Microsoft.
  </para>
 
  <para>
   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
   32-bit PostgreSQL builds are possible with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname> (including Express editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express editions),
+  as well as standalone Windows SDK releases 8.1a to 10.
   64-bit PostgreSQL builds are supported with
-  <productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
+  <productname>Microsoft Windows SDK</productname> version 8.1a to 10 or
   <productname>Visual Studio 2013</productname> and above. Compilation
   is supported down to <productname>Windows 7</productname> and
   <productname>Windows Server 2008 R2 SP1</productname> when building with
   <productname>Visual Studio 2013</productname> to
-  <productname>Visual Studio 2017</productname>.
+  <productname>Visual Studio 2019</productname>.
    <!--
        For 2013 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2013-sysrequirements-vs
@@ -94,6 +94,8 @@
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2015-sysrequirements-vs
        For 2017 requirements:
        https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2017-system-requirements-vs
+       For 2019 requirements:
+       https://docs.microsoft.com/en-us/visualstudio/releases/2019/system-requirements
    -->
  </para>
 
@@ -166,7 +168,7 @@ $ENV{MSBFLAGS}="/m";
       If your build environment doesn't ship with a supported version of the
       <productname>Microsoft Windows SDK</productname> it
       is recommended that you upgrade to the latest version (currently
-      version 7.1), available for download from
+      version 10), available for download from
       <ulink url="https://www.microsoft.com/download"></ulink>.
      </para>
      <para>
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 149213378c..ca965bdf1a 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -467,4 +467,29 @@ sub new
 	return $self;
 }
 
+package VC2019Project;
+
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(MSBuildProject);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{vcver}           = '16.00';
+	$self->{PlatformToolset} = 'v142';
+	$self->{ToolsVersion}    = '16.0';
+
+	return $self;
+}
+
 1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 4ab81d3402..955fc17577 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
 ==========
 
 This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2013 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2013 - 2019. This builds the whole backend, not just
 the libpq frontend library. For more information, see the documentation
 chapter "Installation on Windows" and the description below.
 
@@ -88,11 +88,11 @@ config_default.pl to create the configuration arguments.
 These configuration arguments are passed over to Mkvcbuild::mkvcbuild
 (Mkvcbuild.pm) which creates the Visual Studio project and solution files.
 It does this by using VSObjectFactory::CreateSolution to create an object
-implementing the Solution interface (this could be either a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2013Project or VC2015Project or VC2017Project from
-MSBuildProject.pm) to it.
+implementing the Solution interface (this could be either VS2013Solution,
+VS2015Solution, VS2017Solution or VS2019Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing
+the corresponding Project interface (VC2013Project, VC2015Project,
+VC2017Project or VC2019Project from MSBuildProject.pm) to it.
 When Solution::Save is called, the implementations of Solution and Project
 save their content in the appropriate format.
 The final step of starting the appropriate build program (msbuild) is
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index fc270cfe1c..51711c2bff 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -969,6 +969,34 @@ sub new
 	return $self;
 }
 
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine);    ## no critic
+
+sub new
+{
+	my $classname = shift;
+	my $self      = $classname->SUPER::_new(@_);
+	bless($self, $classname);
+
+	$self->{solutionFileVersion}        = '12.00';
+	$self->{vcver}                      = '16.00';
+	$self->{visualStudioName}           = 'Visual Studio 2019';
+	$self->{VisualStudioVersion}        = '16.0.28729.10';
+	$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+	return $self;
+}
+
 sub GetAdditionalHeaders
 {
 	my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 1a94cd866e..06ad28ab74 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -39,16 +39,28 @@ sub CreateSolution
 		return new VS2015Solution(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
-		or ($visualStudioVersion eq '15.00'))
+	# The version of nmake bundled in Visual Studio 2017 is greater
+	# than 14.10 and less than 14.20.  And the version number is
+	# actually 15.00.
+	elsif ((($visualStudioVersion ge '14.10') &&
+		($visualStudioVersion lt '14.20')) ||
+	       ($visualStudioVersion eq '15.00'))
 	{
 		return new VS2017Solution(@_);
 	}
+
+	# The version of nmake bundled in Visual Studio 2019 is greater
+	# than 14.20 and less than 14.30.  And the version number is
+	# actually 16.00.
+	elsif ((($visualStudioVersion ge '14.20') &&
+		($visualStudioVersion lt '14.30')) ||
+	       ($visualStudioVersion eq '16.00'))
+	{
+		return new VS2019Solution(@_);
+	}
 	else
 	{
-		croak $visualStudioVersion;
-		croak "The requested Visual Studio version is not supported.";
+		croak "The requested Visual Studio version $visualStudioVersion is not supported.";
 	}
 }
 
@@ -70,12 +82,25 @@ sub CreateProject
 		return new VC2015Project(@_);
 	}
 
-	# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
-	elsif (($visualStudioVersion ge '14.10')
-		or ($visualStudioVersion eq '15.00'))
+	# The version of nmake bundled in Visual Studio 2017 is greater
+	# than 14.10 and less than 14.20.  And the version number is
+	# actually 15.00.
+	elsif ((($visualStudioVersion ge '14.10') &&
+		($visualStudioVersion lt '14.20')) ||
+	       ($visualStudioVersion eq '15.00'))
 	{
 		return new VC2017Project(@_);
 	}
+
+	# The version of nmake bundled in Visual Studio 2019 is greater
+	# than 14.20 and less than 14.30.  And the version number is
+	# actually 16.00.
+	elsif ((($visualStudioVersion ge '14.20') &&
+		($visualStudioVersion lt '14.30')) ||
+	       ($visualStudioVersion eq '16.00'))
+	{
+		return new VC2019Project(@_);
+	}
 	else
 	{
 		croak $visualStudioVersion;
@@ -106,17 +131,19 @@ sub _GetVisualStudioVersion
 {
 	my ($major, $minor) = @_;
 
-	# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
-	if ($major > 14)
+	# The major visual studio that is supported has nmake
+	# version >= 14.30, so stick with it as the latest version
+	# if bumping on something even newer.
+	if ($major >= 14 && $minor >= 30)
 	{
 		carp
 		  "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
-		return '14.00';
+		return '14.20';
 	}
-	elsif ($major < 6)
+	elsif ($major < 12)
 	{
 		croak
-		  "Unable to determine Visual Studio version: Visual Studio versions before 6.0 aren't supported.";
+		  "Unable to determine Visual Studio version: Visual Studio versions before 12.0 aren't supported.";
 	}
 	return "$major.$minor";
 }
#18Haribabu Kommi
kommi.haribabu@gmail.com
In reply to: Michael Paquier (#17)
Re: MSVC Build support with visual studio 2019

On Thu, 27 Jun 2019 at 17:28, Michael Paquier <michael@paquier.xyz> wrote:

On Wed, Jun 26, 2019 at 10:29:05PM +1000, Haribabu Kommi wrote:

Thanks for the review. Yes, that patch applies till 9.5, it is my mistake
in naming the patch.

I have been able to finally set up an environment with VS 2019 (as
usual this stuff needs time, anyway..), and I can confirm that the
patch is able to compile properly.

Thanks for the review.

-  <productname>Visual Studio 2017</productname> (including Express
editions),
-  as well as standalone Windows SDK releases 6.0 to 8.1.
+  <productname>Visual Studio 2019</productname> (including Express
editions),
+  as well as standalone Windows SDK releases 8.1a to 10.
I would like to understand why this range of requirements is updated.
Is there any reason to do so.  If we change these docs, what does it
mean in terms of versions of Visual Studio supported?

We stopped the support of building with all the visual studio versions less
than 2013.
I updated the SDK versions accordingly.

-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the
corresponding
-Project interface (VC2013Project or VC2015Project or VC2017Project from
-MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in
Solution.pm,
+depending on the user's build environment) and adding objects implementing
+the corresponding Project interface (VC2013Project or VC2015Project or
VC2017Project
+or VC2019Project from MSBuildProject.pm) to it.
This formulation is weird the more we accumulate new objects, let's
put that in a proper list of elements separated with commas except
for the two last ones which should use "or".

s/greather/greater/.

The patch still has typos, and the format is not satisfying yet, so I
have done a set of fixes as per the attached.

The change in the patch is good.

-   elsif ($major < 6)
+   elsif ($major < 12)
{
croak
-         "Unable to determine Visual Studio version:
Visual Studio versions before 6.0 aren't supported.";
+         "Unable to determine Visual Studio version:
Visual Studio versions before 12.0 aren't supported.";
Well, this is a separate bug fix, still I don't mind fixing that in
the same patch as we meddle with those code paths now.  Good catch.
-       croak $visualStudioVersion;
+       carp $visualStudioVersion;
Same here.  Just wouldn't it be better to print the version found in
the same message?

Yes, that is a good change, I thought of doing the same, but I don't know
how to do it.

The similar change is required for the CreateProject also.

+ # The major visual studio that is supported has nmake version >=
14.20 and < 15.
if ($major > 14)
Comment line is too long. It seems to me that the condition here
should be ($major >= 14 && $minor >= 30). That's not completely
correct either as we have a version higher than 14.20 for VS 2019 but
that's better than just using 14.29 or a fake number I guess.

The change is good, but the comment is wrong.

+ # The major visual studio that is supported has nmake
+ # version >= 14.30, so stick with it as the latest version

The major visual studio version that is supported has nmake version <=14.30

Except for the above two changes, overall the patch is in good shape.

Regards,
Haribabu Kommi

#19Michael Paquier
michael@paquier.xyz
In reply to: Haribabu Kommi (#18)
Re: MSVC Build support with visual studio 2019

On Mon, Jul 01, 2019 at 07:56:29PM +1000, Haribabu Kommi wrote:

We stopped the support of building with all the visual studio versions less
than 2013. I updated the SDK versions accordingly.

I have spent some time looking around, and wikipedia-sensei has proved
to be helpful to grasp the release references:
https://en.wikipedia.org/wiki/Microsoft_Windows_SDK

So the suggestions from the patch are fine. This one was actually
forgotten:
src/tools/msvc/README:from www.microsoft.com (v6.0 or greater).

The similar change is required for the CreateProject also.

I have changed both messages so as the version of VS attempted to be
used is reported in the error message directly.

+ # The major visual studio that is supported has nmake
+ # version >= 14.30, so stick with it as the latest version

The major visual studio version that is supported has nmake version
<=14.30

Damn. Thanks for pointing out that.

Except for the above two changes, overall the patch is in good shape.

OK, committed to HEAD for now after perltidy'ing the patch. Let's see
what the buildfarm has to say about it first. Once we are sure that
the thing is stable, I'll try to backpatch it. This works on my own
dev machines with VS 2015 and 2019, but who knows what hides in the
shadows...
--
Michael

#20Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#19)
Re: MSVC Build support with visual studio 2019

On Tue, Jul 02, 2019 at 02:10:11PM +0900, Michael Paquier wrote:

OK, committed to HEAD for now after perltidy'ing the patch. Let's see
what the buildfarm has to say about it first. Once we are sure that
the thing is stable, I'll try to backpatch it. This works on my own
dev machines with VS 2015 and 2019, but who knows what hides in the
shadows...

The buildfarm did not have much to say, so backpatched down to 9.4,
adjusting things on the way.
--
Michael

#21Haribabu Kommi
kommi.haribabu@gmail.com
In reply to: Michael Paquier (#20)
Re: MSVC Build support with visual studio 2019

On Wed, 3 Jul 2019 at 10:01, Michael Paquier <michael@paquier.xyz> wrote:

On Tue, Jul 02, 2019 at 02:10:11PM +0900, Michael Paquier wrote:

OK, committed to HEAD for now after perltidy'ing the patch. Let's see
what the buildfarm has to say about it first. Once we are sure that
the thing is stable, I'll try to backpatch it. This works on my own
dev machines with VS 2015 and 2019, but who knows what hides in the
shadows...

The buildfarm did not have much to say, so backpatched down to 9.4,
adjusting things on the way.

Thanks Michael.

Regards,
Haribabu Kommi