diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index e64b6a6a3a39d43d6d0b300127de61f1505e4c5c..4b84c98ea2e2f18a61855393926c4552c29bba19 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -23,7 +23,7 @@ sub new {
         includes        => '',
         defines         => ';',
 		solution        => $solution,
-        disablewarnings => '4018;4244',
+        disablewarnings => '4018;4244;4273',
     };
 
 	bless $self;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index c2a30fd40f869123ac5b02bb039bae1267b824bf..ebc7d90506ec1377339097821df41d38ed047a4b 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -9,6 +9,11 @@ environment variables "leaking" through.
 
 First, edit config.pl to reflect what "configure options" you want set.
 
+If you need to modify the environment for calling external tools, such as
+flex or bison, create a file called "buildenv.bat". This file will be called
+by all scripts before anything is done, so the environment can be set up.
+(for example, include SET PATH=%PATH%;c:\some\where\bison\bin)
+
 Then, to build all of PostgreSQL in debug configuration, run the command
 	build
 from a Visual Studio Command Prompt (to get all environment
@@ -54,3 +59,7 @@ Get from http://web.mit.edu/Kerberos/dist/index.html
 
 zlib - required for compression support in pg_dump/pg_restore
 Get from http://www.zlib.net
+
+libxml2 and libxslt - required for XML support
+Get from http://www.zlatkovic.com/pub/libxml or build from source from
+http://xmlsoft.org. Note that libxml2 requires iconv.
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 3b9c64cd0a1aa0ae91637f5202317849677eb092..c55f35d2dc190132aaecb92810a108c45422ed59 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -14,6 +14,11 @@ sub new {
         strver   => '',
     };
 	bless $self;
+	if ($options->{xml}) {
+      if (!($options->{xslt} && $options->{iconv})) {
+         die "XML requires both XSLT and ICONV\n";
+      }   
+   }
 	return $self;
 }
 
diff --git a/src/tools/msvc/build.bat b/src/tools/msvc/build.bat
index 61b85645b205d236402e10e80939db07e7f393cb..8ef282cef4959ccf42ccfe22c8e23ae28eb3819a 100755
--- a/src/tools/msvc/build.bat
+++ b/src/tools/msvc/build.bat
@@ -1,5 +1,7 @@
 @echo off
 SET STARTDIR=%CD%
+if exist src\tools\msvc\buildenv.bat call src\tools\msvc\buildenv.bat
+if exist buildenv.bat call buildenv.bat
 
 perl mkvcbuild.pl
 if errorlevel 1 goto :eof
diff --git a/src/tools/msvc/mkvcbuild.pl b/src/tools/msvc/mkvcbuild.pl
index 91d28bfcd3d2851883a421a8df4bffb59163def3..c87420b0dc8c2c7ba9d9be71ba6b3c8fb5d7e287 100644
--- a/src/tools/msvc/mkvcbuild.pl
+++ b/src/tools/msvc/mkvcbuild.pl
@@ -187,24 +187,21 @@ if (!$solution->{options}->{openssl}) {
 }
 
 # Pgcrypto makefile too complex to parse....
-# Pgcrypto requires zlib
-if ($solution->{options}->{zlib}) {
-   my $pgcrypto = $solution->AddProject('pgcrypto','dll','crypto');
-   $pgcrypto->AddFiles('contrib\pgcrypto','pgcrypto.c','px.c','px-hmac.c','px-crypt.c',
-   		'crypt-gensalt.c','crypt-blowfish.c','crypt-des.c','crypt-md5.c','mbuf.c',
-   		'pgp.c','pgp-armor.c','pgp-cfb.c','pgp-compress.c','pgp-decrypt.c','pgp-encrypt.c',
-   		'pgp-info.c','pgp-mpi.c','pgp-pubdec.c','pgp-pubenc.c','pgp-pubkey.c','pgp-s2k.c',
-   		'pgp-pgsql.c');
-   if ($solution->{options}->{openssl}) {
-   	$pgcrypto->AddFiles('contrib\pgcrypto', 'openssl.c','pgp-mpi-openssl.c');
-   }
-   else {
-   	$pgcrypto->AddFiles('contrib\pgcrypto', 'md5.c','sha1.c','sha2.c','internal.c','internal-sha2.c',
-   			'blf.c','rijndael.c','fortuna.c','random.c','pgp-mpi-internal.c','imath.c');
-   }
-   $pgcrypto->AddReference($postgres);
-   $pgcrypto->AddLibrary('wsock32.lib');
+my $pgcrypto = $solution->AddProject('pgcrypto','dll','crypto');
+$pgcrypto->AddFiles('contrib\pgcrypto','pgcrypto.c','px.c','px-hmac.c','px-crypt.c',
+		'crypt-gensalt.c','crypt-blowfish.c','crypt-des.c','crypt-md5.c','mbuf.c',
+		'pgp.c','pgp-armor.c','pgp-cfb.c','pgp-compress.c','pgp-decrypt.c','pgp-encrypt.c',
+		'pgp-info.c','pgp-mpi.c','pgp-pubdec.c','pgp-pubenc.c','pgp-pubkey.c','pgp-s2k.c',
+		'pgp-pgsql.c');
+if ($solution->{options}->{openssl}) {
+	$pgcrypto->AddFiles('contrib\pgcrypto', 'openssl.c','pgp-mpi-openssl.c');
 }
+else {
+	$pgcrypto->AddFiles('contrib\pgcrypto', 'md5.c','sha1.c','sha2.c','internal.c','internal-sha2.c',
+			'blf.c','rijndael.c','fortuna.c','random.c','pgp-mpi-internal.c','imath.c');
+}
+$pgcrypto->AddReference($postgres);
+$pgcrypto->AddLibrary('wsock32.lib');
 
 my $D;
 opendir($D, 'contrib') || croak "Could not opendir on contrib!\n";
diff --git a/src/tools/msvc/pgbison.bat b/src/tools/msvc/pgbison.bat
index cacd82cb165fe4504c4f7eb38b52f5b380b67d64..f433e0774bd7a176f8be6326411434be03810e22 100755
--- a/src/tools/msvc/pgbison.bat
+++ b/src/tools/msvc/pgbison.bat
@@ -1,4 +1,6 @@
 @echo off
+if exist src\tools\msvc\buildenv.bat call src\tools\msvc\buildenv.bat
+
 SET BV=
 for /F "tokens=4 usebackq" %%f in (`bison -V`) do if "!BV!"=="" SET BV=%%f
 if "%BV%"=="" goto novarexp
diff --git a/src/tools/msvc/pgflex.bat b/src/tools/msvc/pgflex.bat
index ae200428146e5484135d9bf2ce7afe3f7b42f209..17ea4ff6e25c3e16576e625d51737b5c5cf85030 100755
--- a/src/tools/msvc/pgflex.bat
+++ b/src/tools/msvc/pgflex.bat
@@ -1,4 +1,6 @@
 @echo off
+if exist src\tools\msvc\buildenv.bat call src\tools\msvc\buildenv.bat
+
 flex -V > NUL
 if errorlevel 1 goto noflex