I've got a directory containing multiple files that I want to include in my msi package build by a Wix project.
/database
/database/migration11.txt
/database/migration21.txt
/database/migration32.txt
Those files change often or there are new ones added, and I don't want to adapt my Wix file with every new migration file.
Basically I want to say in my wxs file to include all files in the directory database and upon installation put them in the directory [INSTALLLOCATION]/database.
Any way to achieve this?
ADDED:
Just found this workaround: use HEAT but I'm curious if there is another, recommended way.
You can use task in your wixproj file:
<ItemGroup>
... Your wxs files ...
<HarvestDirectory Include="$(variable)\YourDirectory\">
<ComponentGroupName>CG_YOUR_GROUP</ComponentGroupName>
<DirectoryRefId>DIR_REFERENCE</DirectoryRefId>
<AutogenerateGuids>false</AutogenerateGuids>
<GenerateGuidsNow>false</GenerateGuidsNow>
<SuppressUniqueIds>true</SuppressUniqueIds>
<SuppressCom>true</SuppressCom>
<SuppressRegistry>true</SuppressRegistry>
<SuppressRootDirectory>true</SuppressRootDirectory>
<PreprocessorVariable>var.Property_Preprocessor</PreprocessorVariable>
</HarvestDirectory>
</ItemGroup>
This task calls Heat during the build. Hope this helps you.
If anyone still needs this, here is a sample of HarvestDirector with wixproj. Thanks to DavidEGrayson.
Related
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.
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.
I am in the process of migrating all my projects one by one from Installshield to Wix and I would like to find out the best way to deal with env specific files.
Our current process is:
Using Installshield we create a base MSI and a Transform file which would install the base MSI and a directory structure with files present in the current directory. Ofcourse in my source control, I have separate config files for different environments and my Deployment script picks up the right set of files and puts them in a staging location.
For example, Current dir looks like as follows:
sample.msi
sample.mst
test\apps\docs\global.config
test\files\docs\global.config
sample.msi gets installed and the above directory structure gets copied to the target location.
During Uninstall the directory structure gets removed as well.
I tried to recreate this behavior using CopyFile element but during uninstall the copied files stay and do not get removed. Is there another way to achieve this?
I understand the way we do our packaging might not be the best way to get around our requirements. If someone has a better way to do this, please let me know.
I am still very new to Wix and I haven't looked at any of the wix extensions so wouldn't know what else is out there.
As always, any help is greatly appreciated.
Do these files really have to be seperate from the msi?
Using wix you could put them all into the msi and install them based on certain conditions like settings properties or using a custom action. Doing it that way should make it rather easy to let the msi create the directories and copy the files, and also remove them when uninstalling.
Conditions would work like this:
<Component Id='MyComponent' Guid='PUT-GUID-HERE'>
<Condition><![CDATA[YOUR-PROPERTY = "SOME_STRING"]]></Condition>
<File Id='readme' Name='readme.txt' DiskId='1' Source='readme.txt' />
</Component>
A CustomAction in Wix can be a .net dll, the manual explains how this is done here:
Adding Custom Actions
IF you have the WIX Toolkit installed you just need to create a Custom Action Project.
I've a PowerShell script that generates a partial class based on a resource file I've in my cs project.
I'd like to include this new file during compiling time.
Is the Exec Task the way to go? And if so, any examples of how to accomplish this?
You could accomplish this by modifying your .csproj file to automatically include files of a particular pattern, e.g.
<ItemGroup>
<Compile Include="GeneratedPartialClasses\*.cs" />
</ItemGroup>
Note that Visual Studio will also load these files as part of your project, so you may need to be careful that these generated files aren't accidentally checked-in to source control.
I've got a WiX project which pulls in a WiX Fragment with a load of supporting files.
I'm using Paraffin to build the wsx file for the fragment. At the moment I manually run a one line batch file to run with paraffin with the appropriate arguments whenever I make a change the supporting files folder.
Instead I would like paraffin to run as part of the build process. I'm guessing I need to add something to inside the .wixproj file, but I'm not actually sure what.
How do I do this?
Found a solution:
<Target Name="BeforeBuild">
<Exec Command="paraffin -dir SourceDir -groupname MyGroupId -dirref MyDirId output.wxs"/>
</Target>