The solution is to use uuidgen
uuidgen -c
will generate the appropriate ProductCode.
The following batch script will update the product code and allow for an overwrite install when applied through a build server prior to performing a release build.
REM
REM Batch file to set the release number and version number for a production release
REM
REM
if not defined RELEASE_VERSION exit /b 1
if not defined BUILD_NUMBER exit /b 1
if not defined SVN_REVISION exit /b 1
set SDKBIN=%PROGRAMFILES%\Microsoft SDKs\Windows\v7.0A\Bin
if defined PROGRAMFILES(X86) Set SDKBIN=%PROGRAMFILES(X86)%\Microsoft SDKs\Windows\v7.0A\Bin
REM Change the version details in the WindowsInstaller project
fart WindowsInstaller\WindowsInstaller.vdproj "\"ProductVersion\" = \"8:1.0.0\"" "\"ProductVersion\" = \"8:%RELEASE_VERSION%.%BUILD_NUMBER%\""
if %ERRORLEVEL%==0 exit /b 1
for /f %%i in ('"%SDKBIN%\uuidgen" -c') do set PRODUCTCODE=%%i
if not defined PRODUCTCODE exit /b 2
fart WindowsInstaller\WindowsInstaller.vdproj "\"ProductCode\" = \"8:{2DD6303F-BF0C-4CD5-9AAC-171C577FFEAD}\"" "\"ProductCode\" = \"8:{%PRODUCTCODE%}\""
if %ERRORLEVEL%==0 exit /b 1
exit /b 0
I use fart to perform the regex replacement in the source file.