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 ...).
Related
as for now, what I did was to painstakingly query a directory get the file names and one by one create a and as dependency of the product.
I have tried i am getting errors but I am also confuse as to whether its possible or not.
My directory lies in the same folder as the Wix project and it contains files and subdirectory.
I have like 200 files total and it seems like doing it one at a time is tedious with directories and subdirectory.
Pre-note: The following are my notes from the times when I was using Wix extensively. They are a little old (from around 2017-2018) but may help you for harvesting directories.
When a project contains many files to install, it will take too much time to create file and component elements for all of them. One of the tools that is shipped with WiX (heat.exe) could create these as well.
The general syntax for Heat is:
heat.exe harvestType harvestSource <harvester arguments> -o[ut] sourceFile.wxs
Heat can look at a directory, evaluate all the files in it, and create a .wxs file defining the components needed to install all those.
HarvestType
dir: harvest a directory
file: harvest a file
payload: harvest a bundle payload as RemotePayload
perf: harvest performance counters
project: harvest output of a VS project
reg: harvest a .reg file
website: harvest an IIS website
HarvestSource
It is the path to the directory (relative or absolute) which should not end with a backslash.
Without supplying several arguments, the output of heat is not as helpful as it should be:
All directory element names will be impromptu folders supplied to heat.exe, which will not be after an installation.
All guids are “PUT-GUID-HERE”. Heat can generate its own guids.
Source attributes of all File elements are set to “SourceDir\Filename”.
Components will not be grouped as a ComponentGroup.
To fix these issues, the following arguments should be supplied:
-cg: create a componentgroup with the supplied name
-dr : Name of the directory that will be created on the end-user's computer.
-gg: create GUIDs instead of fillers
-g1: do not use curly brackets for guids
-sfrag: use a single Fragment for everything
-srd: not to harvest the folder itself where files are
-var: a preprocessor variable can be used to insert in place of sourceDir.
-scom: suppress com element harvesting
-sreg: suppress registry harvesting
heat.exe dir “D:\Documents\heatf” -dr MyProgramDir -cg NewFilesGroup -gg -g1 -sfrag -srd -sreg -scom -var “var.MyDir” -out “.\heatfile2.wxs”
Now the components are grouped, each component has Guid, and installed to “MyProgramDir” folder, and file elements use the preprocessor variable supplied.
In order to use this fragment file in the main file, referencing ComponentGroup “NewFilesGroup” under a Feature is enough:
<Feature Id…>
<ComponentGroupRef Id=”MyFilesGroup” />
</Feature>
It should be remembered that every time Heat is run on a directory and -gg flag is set, new Guids will be created for components. If a version is already installed at end users, the guids of the components should never change, as doing so will prevent Windows from accurately keeping track of them. Heat will also create new Id attributes for File and Component elements each time it is used.
Note: If the binary files (dll and exe) are compiled with the flag “COM Visible”, then heat will generate the com class registrations (registry and COM element harvesting) as well in the wsx file.
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.
I am new to using WiX so this my be a dumb question. I am trying to keep the GUID generated by the harvest tool (heat.exe) consistent for files that I am packaging. Everyone seems to say that as long as the file path and sub path remain same heat.exe will generate the same GUID for a file. Unfortunately, I am not seeing that behavior. My workflow is as follows.
Copy all the deliverable files to a staging directory during my build process. Then run heat.exe in the staging directory to generate the component fragment wxs file. Before I copy the file into the staging directory I clear all my old files.
I want to add the generated wxs file into my source control so that I can achieve minor upgrades. If my understanding is correct for me to achieve that I need to have consistent GUID across my builds so that I can track them.
The command line I use for generating the wxs file is as follows:-
c:\foobar\build\>C:\win32\wix-3.7.1224.0\heat.exe dir . -cg MyCG -dr INSTALLDIR -g1 -gg -nologo -sreg -suid -t C:\foobar\src\support\packaging\wix\foo.xslt -var var.foobarSource -out c:\foobar\src\support\packaging\wix\foo.wxs
What I see that the GUID generated are different during each run. Is there was a way for me to keep GUID consistent.
You should specify -ag flag.
-ag
Auto generate component guids at compile time, e.g. set Guid="*".
As long as your file paths are the same, generated GUID's will be the same for files.
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
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