diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index d7dbc5de5c5f33815fbc93d854c4c2de63f4ffc3..850a1dfabcf58907bf5a41314309e6eb75c8b77d 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -275,6 +275,9 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY
 		system(
 "perl -I ../catalog Gen_fmgrtab.pl ../../../src/include/catalog/pg_proc.h");
 		chdir('..\..\..');
+	}
+	if (IsNewer('src\include\utils\fmgroids.h', 'src\backend\utils\fmgroids.h'))
+	{
 		copyFile('src\backend\utils\fmgroids.h',
 			'src\include\utils\fmgroids.h');
 	}