How to specify Assembly attribute in a WiX Fragment generated using Heat.exe from the command line - wix

I am using Heat.exe to harvest a directory containing my DLLs that need to go into the GAC. The fragment is correctly created and I can build my MSI. The problem I am having is that after the wxs source file is created I have to manually edit the file adding the File/#Assembly =".net" attribute.
Is there a way to have heat include Assembly=".net" for each File when using heat.exe from the command line?
Using WiX 3.0.

There's no ad hoc attribute for this, probably because you can have your own rules, which files need this attribute, and which do not.
However, you can apply XSLT transform to the heat output and adjust the resulting XML (WXS file) the way you need. Take a look at -t:<xsl> switch for more details.

Related

How do i pass parameters between wxs files in WIX?

I have constructed a bootstrapper bundle with WIX 3.8, in which i pass a given parameter (by DOS-window) for the installation directory to the MSI file.
All works fine.
But now we want to put a second WXS file between the bootstrapper and the MSI.
This one is called Source.wxs and contains the variable for the installation directory and the MsiPackage-tag (which was in the bootstrapper file before), which will start the MSI.
The big question is: How can i pass my parameter from the bootstrapper to the second WXS file?
Thanks in advance!
Patrick
The question "How can i pass my parameter from the bootstrapper to the second WXS file?" displays some lack of understanding.
You see, the second WXS file is (or at least should be) part of your MSI. I assume you added that wxs file directly into the wix setup project, or into a wix library referenced by your wix setup project. Either way, your main wxs file (the one with the <wix> element) will need to pull in the fragment in the second wxs file (by referencing a component or a property etc.).
Once you pull in the contents of the second wxs, any properties defined in it will be part of the wix setup project, and any appropriately-named command line parameter supplied by the bootstrapper will be fed into the correct property, regardless of which wxs file it came from.
If you have a variable name "App_Name" and value as Test in your wix file and wants to use in wxs file you can use as !(loc.App_Name)
example: wix file contains below variable
<String Id="App_Name" Overridable="yes">Test</String>
your wxs can use like this
<Product Name='!(loc.App_Name)'

Using heat.exe tool output file in setup project

I generate setup file list using heat.exe but I can't find out how I can use it in my wix setup project.
Can I import output file to my setup project?
MSBuild supports using wildcards (**, * and ?) to specify a group of files as inputs instead of listing each one separately. If you add something like the following to your project file, every wxs file in the same directory as your project file will be included in your build.
<ItemGroup>
<Compile Include="*.wxs" />
</ItemGroup>
According to this bug, Votive (WiX VS package) does not yet support wildcards, although it does work on my machine. Your mileage may vary. This, of course, is not an issue if you're not using Visual Studio to work on your setup.
Another solution would be to create the file and add it to your project file. Every time you'd build your setup, you would call heat and overwrite the file.
Afterwards, you just need to reference one of the generated elements in your setup to import the fragment. You can do this by using the -cg switch in your heat command.

Is there anyway to get heat to use a file genereated by heat as a source for guids?

I've just started looking at wix again now that it looks like installer projects are going to be deprecated from VisualStudio. We have a third party application that is "install via xcopy", which makes it hard for us to track in terms of versioning so we'd like to create an msi for it. There are several hundred files that are part of the installation.
I'd like to use heat to create the list of files for the installer, but I've heard that it's not good to use heat to create the wxs file more than once with autoguids because then your installer will have issues.
I was wondering if in wix 3.6, there was a command line parameter to heat which would take a previously generated wxs file as the source for guids? I want heat to autogenerate guids for any new files, but use the previous output of heat as a database for existing files.
If you use the -ag flag this will set the guids to be generated at compile time and as long as the path doesn't change the compiler will keep the same guid for each component. Rather than use a command-line to do the harvesting it is better to edit the *.wixproj file and add a HeatDirectory element.

How can I register a COM-Object with Windows Installer XML

I have got the following Problem: In my WiX Setup I need to register a COM Object. I have got a ".tlb" File and a ".dll" File (in my example: XYCommon.dll and a XYCommon.tlb)
Now I want to make the Setup to Register the TLB.
How Can I do this in Windows Installer XML ?
My first try was to work with a CustomAction and Open "Regasm.exe" and Register it - but I dont know how I can bring the Regasm.exe to Register the XYCommon.tlb
Any Help ? Thanks
Use the WiX harvester utility called Heat. It will generate the WiX source that contains the necessary registry entries to correctly register (and unregister) your COM objects.
Will your COM objects (XYCommon.dll and XYCommon.tlb) change often?
If no: then just run Heat on those two files (read up on the command-line parameters and experiment with them to get the desired output), clean them up if necessary, and add them to your project.
If yes:
If you want to try to run Heat as a Visual Studio prebuild event, this SO answer should give you some guidance: Add a folder to installer in wix not files?
Sometimes when you use Heat you still need to tweak then generated .wxs files a little. Therefore you may want to write some wrapper utility that calls heat on a list of files or a directory, then cleans up the output how you would like. Then you can add the utility to your build process.
Example of using heat on an individual file:
heat.exe file myFile.dll -gg -g1 -suid -svb6 -out myFile.wxs
Example of using heat on an entire directory:
heat.exe dir myDirectory -gg -g1 -suid -svb6 -out myDirectory.wxs
Breakdown of some of the parameters I used:
heat.exe: you'll have to specify the full path to the executable if it's not in your path
file myFile.dll: specify that you want to run heat on the single file, myFile.dll
dir myDirectory: specify that you want to run heat on the directory, myDirectory
gg: generate guids for the components
g1: generate guids without the curly braces
suid: suppress creating uniquely generated ids for files and components, instead use the file names as the ids
svb6: suppress harvesting COM information for the VB6 runtime. Note: If you want to register COM objects that use the VB6 runtime, you need to use this flag so that you do not overwrite your VB6 runtime registry entries

Add a folder to installer in wix not files?

My installer has to copy files into installdir... My application has around 2000 files and it is not possible for me to write the script to add each and every file to the installer.
Is there any option in wix so that I can add all the files or the entire folder consisting the files at once? I am new to wix and i didnt find any option in any tutorial for this... Please do assist me and thanks in advance.....
Heat is the WiX harvest tool. You can run it on a directory to generate the necessary WiX source code.
EDIT:
If you want to run heat before your VS project builds, add it to your project prebuild events as seen in the screenshot below (this is how I have my project setup to dynamically generate WiX source for our ever changing help content):
Note the -var wix.HelpSource switch that I have. The WiX source files generated by heat will set the location of the source files to that variable instead of hard-coding it. So the generated source will have components that look something like this:
<Component Id="Welcome.htm" Directory="Content" Guid="INSERT-GUID-HERE">
<File Id="Welcome.htm" KeyPath="yes" Source="!(wix.HelpSource)\Content\Welcome.htm" />
</Component>
And in my particular case, I define that variable on the Tool Settings screen of my WiX VS project to the relative directory ..\..\Help\Output as seen below:
NOTE: Harvesting files in this manner will cause the GUIDs of the components harvested to change every time you build. If you don't want your GUIDs to change, you may have to write some wrapper that calls heat to harvest the files, then updates your original WiX source, leaving all the GUIDs alone.