WIX Heat Parameters to Set Properties - wix

I am new to Wix Toolkit. I am creating an .msi for a console application. Below is my one of my line which is generated using heat command :
<Component Id="cmp2B116558C64AF876AD223372FA4B8DFF" Directory="dir99DE416F55C8960850D5A4FCA3758AD4" Guid="PUT-GUID-HERE">
<File Id="fil19E0EEE3E5D0208523116CAFE9E9B06E" KeyPath="yes" Source="$(var.SourceDir)\App.config" />
</Component>
I just need that PUT-GUID-HERE to be get set automatically. Is there anything that i need to change in my heat command. Below is my heat command which i am using.
heat dir "C:\Users\rp5026921\Documents\Project\Automation Testing\SourceCode\MeridianAutomation\bin\Release" -cg ComponentsGroup -out "C:\Users\rp5026921\Documents\Project\Automation Testing\SourceCode\MeridianAutomationSetUp\MeridianAutomationComponents.wxs" –gg
One more issue is that, i am having app.config in my console application. In that i need to change certain values after installing the .msi. But after installation when i go inside the folder its not allowing me to edit the app.config file.

You are using the right command line option but just move the "-gg" before the "-out" command line option as shown below.
-gg : Generate guids now. All components are given a guid when heat is run.
-ag : Auto generate component guids at compile time, e.g. set Guid="*".
heat dir "C:\Users\rp5026921\Documents\Project\Automation Testing\SourceCode\MeridianAutomation\bin\Release" -cg ComponentsGroup -gg -out "C:\Users\rp5026921\Documents\Project\Automation Testing\SourceCode\MeridianAutomationSetUp\MeridianAutomationComponents.wxs"

Related

How can I use bindpaths to create a WiX Patch?

I'm using cmake/cpack to build my project with WiX.
cmake runs heat.exe (or something similar) which produces files.wxs that contains the files of my project in the following format:
We'll assume a single file named a.txt inside a folder named "bin". The project is built in NewFolder on the Desktop.
<DirectoryRef Id="CM_DP_bin">
<Component Id="CM_CP_bin.a.txt" Guid="*">
<File Id="CM_FP_bin.a.txt" Source="C:/Users/mindlessbot/Desktop/NewFolder/_CPack_Packages/WIX/packageName/bin/a.txt" KeyPath="yes"/>
</Component>
</DirectoryRef>
After the MSI is created, the whole NewFolder is moved in a different directory (on our server). As a result, when I try to create a WiX Patch using the output .wixpdb, I get the following error:
error PYRO0103 : The system cannot find the file 'C:/Users/mindlessbot/Desktop/NewFolder/_CPack_Packages/WIX/packageName/bin/a.txt'
After some googling, I found out that the .wixpdb contains references to the files, which have changed location, so of course it can't find them. I found a thread where someone provided the commands to use bindpaths, however since I'm using cpack I can't directly call them.
So how should I got about doing this?
Some additional info:
My project contains multiple wxs files (not sure if it makes any difference)
The cpack command is:
path/to/cpack.exe -G WIX --config path/to/config.cmake
The patch command is run separately:
torch.exe -p -xi path/to/oldInstaller.wixpdb path/to/newInstaller.wixpdb -out path/to/patch.wixmst
candle.exe path/to/patch.wxs -out path/to/patch.wixobj
light.exe path/to/patch.wixobj -out path/to/patch/wixmsp
pyro.exe path/to/patch.wixmsp -out path/to/patch.msp -t PatchBaselineID path/to/patch/wixmst
In the event that you would like to build your MSIs on one machine, but build the patch on another, I recommend using the .wixout approach rather than relying on the .wixpdb approach. A .wixout file may be generated by the same WiX Toolset CLI tool that is used to build the MSIs, light.exe. The .wixout
Full documentation on the WiX Toolset linker, light.exe, may be found here. The following is an example use of light.exe to build a .wixout file:
"C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe" "/path/to/Some.wixobj" "/path/to/Another.wixobj" "/path/to/AndYetAnother.wixlib" -bf -xo -out "/path/to/MyInstaller_v1.wixout"
So now let's breakdown what these command line parameters are for:
"/path/to/Some.wixobj" "/path/to/Another.wixobj" "/path/to/AndYetAnother.wixlib" - These are the compiled outputs of WiX source files, they may be either .wixobj files (generated through candle.exe) or .wixlib files (generated through lit.exe, a way of consolidating .wixobj files into one, shareable library).
-bf - This switch causes all of the files to be bound int the resulting .wixout file. This is what removes the need to have the exact folder structure on the target machine when building patches, because the files are carried with the .wixout file.
-xo - This switch tells the linker to output an XML representation of the MSI, instead of the actual MSI. This is required to use the -bf switch.
-out "/path/to/MyInstaller_v1.wixout" - This tells the linker where to output the .wixout file.
Once you have the capability of generating .wixout files, the torch.exe command can be modified to run based on .wixout files instead of .wixpdb files and their associated folder structures. The following is how I would modify your torch.exe command to use .wixout files as opposed to .wixpdb files:
torch.exe -p -xi "path/to/oldInstaller.wixout" "path/to/newInstaller.wixout" -out "path/to/patch.wixmst"
So, all in all I really like this approach, and generally I make my build process produce both an .msi and a .wixout file. This allows us to cache various builds/versions of our installer as .wixout files, and then the process of creating a patch between various versions of the .wixout files becomes relatively easy.

Heat harvest Payload for ExePackage

I have a Compressed file (Self-extracting) that was included as a ExePackage for the current BootStrapper project I'm working on.
I was asked to Unzip the package before including it in the BootStrapper, so that the end user doesn't have to unzip the file before starting the install process of that package.
Excluding the install application, there is two folders (win32 && win64) that contain 288 files each, I need to create a PayloadGroup out of these files. I started doing this by hand, but after looking at Heat element, I saw that Heat can generate Payloadgroup.
How can I harvest from the directories the Payloadgroup that is required for this package.
Doing this manually is a very long process ...
If using Visual Studio you're supposed to be able to go in your setup project's references and click on the reference in question and set Harvest to true.
If I recall this had some issues, and some online sources said it wasn't working for them, I'm not sure at the moment. Which is why I called heat from the command line in a post-build event. Something like this:
call "$(WIX)bin\heat.exe" dir "$(TargetDir)." -var var.$(ProjectName).TargetDir -dr INSTALLFOLDER -cg Binaries -gg -g1 -ag -scom -sreg -sfrag -srd -o "$(SolutionDir)Setup$(ProjectName)\$(ProjectName).Binaries.wxs"
You can even specify an XSLT transform that filters your generated wxs file. For more info check this helpful blog post
I implemented heat.exe dir -generate payloadgroup in v4.0 (https://github.com/wixtoolset/issues/issues/3470). In v3.x, the -generate option was only supported by project harvesting (heat.exe project ...).

WIX Heat, Change the name of the subdirectory through heat?

So I am using Wix to install my application, it works great and does everything that I need. The one issue I am having now is this. I am using the following command line argument in my VS 2010 Pre-build Event command:
heat.exe dir "C:\My Main Folder" -cg MyApplication -gg -scom -sreg -sfrag -dr APPLICATIONROOTDIRECTORY -var var.MyApplication -out "..\..\MyApplication.wxs"
My issue is that the .wxs file that is generated gives me the following folder structure:
<Fragment>
<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
<Directory Id="dirB19DCB4311BD6C765579FE56A2C72DF8" Name="My Main Folder">
My question is if there is a way to pass in an argument that could change the name of the "My Main Folder" directory, because as of right now I am changing it manually but this is extremely inefficant and makes it so that we cannot have an automated build process. If anyone has any suggestions or places I could look that would be great! Right now I am leveraging the "WiX: A Developer's Guid to Windows Installer XML" book to try and find a solution but am not finding anything.
Depending on exactly what you are aiming to do, I would be tempted to use -srd to suppress the generation of the root directory and then change the -dr parameter to point at the directory with the correct name.
Other than that, I think the only other simple option is probably an XSL transform, which you can use by specifying the -t parameter.
As ChrisPatrick suggested you can use the -srd to suppress the generation of the root directory and use your own with -dr.
heat.exe dir "C:\My Main Folder" -srd -dr "DIRNAMEHERE"
You can find more information here, heat documentation

WIX HeatProject, how to use visual studio 2010

I have recently converted visual studio setup projects to wix project. Everything great, except that you have to ist every file manually. Is there something similar to adding project output (VS studio setup project). I read something about HeatProject task but don't know how to use it, could not find any documentation or example of the same.First question,is it possible to add project output instead of adding files one by one if yes then how?
Heat offers same functionality like tallow, or paraffin. Paraffin will generate .wxs fragment file containing list of all files which will be deployed. Using parameters you can set which files you want and more.
Example
%1\Paraffin.exe -dir "..\..\..\..\Web\HostDir" -dirref INSTALLLOC -custom APPL ..\..\WebFragment.wxs -guids -ext .csproj -direXclude obj -multiple
We use heat.exe to harvest our app files as follows. The %FULL_PUBLISH_PATH% is the full path to the directory that we instructed msbuild to publish the webapp to.
"%WIX_TOOLS_PATH%heat.exe" dir %FULL_PUBLISH_PATH% -dr WEBAPPLOC -ke -srd -cg ComponentNameToUse -var var.publishDir -gg -out FileNameToUse.wxs

Wix Heat output not referencing directory like I want

So here's the basic setup. I have an existing WIX project that builds a bunch of individual fragments in to a larger MSI. I'm trying to change the project around to allow you to select individual pieces to install. The program I've run in to is that when I run heat on the smaller directories to create the individual components, the Source path isn't correct. I'll give an example as hopefully that will make more sense.
So I have basic folder structure like this:
C:\ProjDir\Foo\Bar1
C:\ProjDir\Foo\Bar2
I used to a command to simply harvest C:\Foo (Heat.exe dir Foo -dr FOO_DIR_REF -out File.wxs), and now I've changed it to to harvest each individual Bar folder (Heat.exe dir Foo\Bar1 -dr BAR1_DIR_REF -out File1.wxs) and (Heat.exe dir Foo\Bar2 -dr BAR2_DIR_REF -out File2.wxs). The problem I'm having is that the output of the harvest looks like this:
<Component Id="cmpblablabla" Guid="{stuff-here}">
<File Id="filblabla" KeyPath="yes" Source="SourceDir\Bar1\file.here" />
</Component>
And when trying to build the msi it complains because it can't find SourceDir\Bar1. Basically what I need is a way to make it look something like this:
<Component Id="cmpblablabla" Guid="{stuff-here}">
<File Id="filblabla" KeyPath="yes" Source="SourceDir\Foo\Bar1\file.here" />
</Component>
This seems like a very simple problem, that I'm sure is easily done, but all the searching I've done has not come up with anything useful.
Note that light will search additional SourceDir's for your file if you add them to the search path with -b
e.g.
light.exe -b Foo ...
It should be
<Component Id="cmpblablabla" Guid="{stuff-here}">
<File Id="filblabla" KeyPath="yes" Source="$(var.ProjectName.TargetPath)\Bar1\file.here" />
</Component>
Different properties available are
$(var.ProjectName.TargetPath)
$(var.ProjectName.ProjectDir)
The answer to your question is all in heat.exe help text. :-)
In order to end up with correct directory harvesting, point the heat to your root directory (Foo), and specify the -srd switch in the command line. As the help text states, this will omit root dir harvesting and you'll most likely end up with what you need.
For even more flexibility, you can specify -var switch providing the WiX variable which is to replace the SourceDir explicit statement. Again, just run heat.exe and look through the output - you'll find enough info and examples.