从命令行生成的Windows Installer升级代码 [英] Windows installer upgrade code generated from command line
问题描述
我正在使用Windows Installer安装/升级安装.
I am using the windows installer to install/upgrade an installation.
使用Visual Studio,我可以手动更改版本号,然后在要求更改ProductCode时选择是".只要在安装程序项目上设置了以下属性,这将创建一个能够覆盖现有安装程序的安装程序
Using Visual Studio I can manually change the version number and then select yes when asked to change the ProductCode. This creates an installer that is capable of overwriting the existing installation provided that the following properties are set on the installer project
RemovePreviousVersions True
DetectNewerInstalledVersion True
现在,在构建服务器中,我可以在.vdproj项目中将版本号更改为适当的新版本.
Now in my build server I can change the version number to the appropriate new version in the .vdproj project.
有人可以建议如何从命令行或批处理脚本为项目生成新的产品代码吗?
Can somebody advise on how to generate a new ProductCode for the project from the command line or a batch script?
推荐答案
解决方案是使用uuidgen
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
我使用 fart 在源文件中执行正则表达式替换.
I use fart to perform the regex replacement in the source file.
这篇关于从命令行生成的Windows Installer升级代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!