Hello all,

We had a requirement to show the configuration in the msi name because we
have several validation steps along the way. For the benefit of others, here
is how to do it using PostBuild events to call a bat file which renames the
file. The system supplied parms pertaining to path all include the trailing
backslash.

1. In the Wix project, we added a BatFiles folder containing RenameMSI.bat

2. In the Wix project properties, we added this to the Build Events,
Post-build Event Command Line
    Use double quotes everywhere in case something contains an embedded
space
call "$(ProjectDir)BatFiles\RenameMSI.bat" "$(ConfigurationName)"
"$(TargetName)" "$(TargetDir)"

3. The contents of RenameMSI.bat are as follows:
@Echo Off

:: Renames msi file to include the configuration (e.g. MyInstaller.msi ->
MyInstaller Debug.msi or MyInstaller Test.msi)

:: Example usage - use double quotes in case anything contains embedded
spaces
:: call "$(ProjectDir)BatFiles\UpdateMSI.bat" "$(ConfigurationName)"
"$(TargetName)" "$(TargetDir)"

:: current configuration (e.g. Test or Debug)
@if '%1'=='' goto End

:: output msi file name without extension (e.g. MyInstaller)
@if '%2'=='' goto End

:: output msi file full path including trailing backslash (e.g.
c:\my\installer\path\)
@if '%3'=='' goto End

cls

:: Strip double quotes and assign to variables
set configuration=%~1
set targetName=%~2
set targetDir=%~3

:: New name is a combination of the existing msi file and the configuration
(e.g. MyInstaller Test.msi)
set newName=%targetName% %configuration%

goto SkipEchoes

@echo.
@echo parm1:  %1, %configuration%

@echo parm2:  %2, %targetName%

@echo parm3:  %3, 
@echo         %targetDir%

@echo newMsi: %newName%.msi
@echo.

:SkipEchoes

:: Delete existing new name msi if it exists (e.g. MyInstaller Test.msi)
del "%targetDir%%newName%.msi"

:: Rename the new msi to include the configuration
ren "%targetDir%%targetName%.msi" "%newName%.msi"

:End

exit 0




--
View this message in context: 
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/How-to-use-PostBuild-event-code-to-include-configuration-in-msi-name-eg-MyInstaller-Test-msi-tp7584890.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to