How do you make a WiX project build when dependent files have changes? - msbuild

I've adopted a Visual Studio solution that contains a number WiX projects. We build the solution from an MsBuild script to generate the product's installer msi.
The problem I'm experiencing is that if I build (and don't rebuild), even if exe's and dll's get updated that need to be put in the installer, the WiX build system doesn't seem to detect this and skips building the installer as it thinks it's already up to date.
How do I work out what the dependencies are that are needed to build a WiX project, and how do I tell the Wix build system to watch out for them changing so it knows to build instead of skip?
Thanks.

This facility was added to WiX 3.6 with little fanfare - in the WiX 3.6 release notes it simply says ".wixproj MSBuild projects support incremental build."

The WiX MSBuild targets don't currently support payloads as inputs into the build process, so nothing tells MSBuild that the WiX targets need to be called. Feel free to file a feature request at wix.sf.net; a couple of us have been talking about ways to do it.

If you can include the projects that create the exe's and dll's into the solution containing the wix projects, you can add project references from the wix projects to the appropriate application projects. Then wix should properly perform incremental builds.
I configure my wix projects to only be included in the release configuration so that the apps can be quickly built and run without creating the install in the debug configuration.

Related

Building an installer, to install dlls to the gac, with MSBuild

I have a dll project which I need to install into the GAC, on our Production machines.
(I wish I didn't have to use the GAC but SSIS insists)
gacutil.exe is not available on the target machines and using "Enterprise.Services" from PowerShell does not work (I don't know why)
My understanding is I should created a msi installer project.
However after installing the Setup and Deploy Extension to Visual Studio (2015 soon to be 2017), I discovered those projects cannot be built by our Build Server because it uses MSBuild, and MSBuild can't build vdproj project files.
What is the correct way, using a CI build pipeline (MSBuild), to create build artifacts, which can install dlls to the GAC, of a Production Environment?
Note: there are several partial answers on SO, but I could not find any, which were up to date/answer my whole question. Please keep that in mind when answering.
You need to break this down into several user stories. You aren't finding partial answers, you are finding actual answers for specific questions. What you ask is more like an epic.
In general I would create an MSI using Windows Installer XML. WiX/MSI can install files to the GAC without using GACUTIL. If you use the WiX Visual Studio extension "Votive" you can create a .SLN / .WIXPROJ / .WXS that can be built using MSBuild. You can then put this into a source control system such as Git/TFVC/Subversion and use a build system such as VSTS V.Next Build, XAML Build, Concourse, Jenkins to automation the pipeline to build the MSI.

How to define WIX agent requirement in TeamCity?

I have add a WIX installer project to solution in Visual Studio 2013. The project is built with every commit on TeamCity. There are several build agents connected to TeamCity cloud, but only some have WIX installed.
Usually I would add the build agent requirement, so only the computer with WIX installed is selected for automated build.
What requirement should I select? Is there some environment variable I could use after WIX is installed?
I know I can set the environment variable manually on every computer I install WIX, but this is not nice solution for me.
There's a system environment variable called 'WIX', which holds the path WiX Toolset is installed to. It is created during WiX Toolset installation.
However, there might be a better way that avoids setting up any build agent requirements. Take a look at this article that explains how to integrate WiX into daily builds. Basically, it suggests committing the required binaries along with the source code of your app.
Both approaches have pros and cons, it's your choice.
The agent need to be restarted after installing WIX. Then there will be
env.WIX
requirment in the Teamcity.

What's the simplest way to ensure that WiX projects build without having to install the toolkit?

I've had some trouble getting WiX projects to build on build servers. One of the pain points has been that my WiX projects are referencing libraries in c:\program files... and the build process calls executables in the same path. This is a bummer because I have to install WiX toolkit in order to get my project to build.
What's the best way to eliminate this headache by having all build tools local to the project being built?
Is there a nuget package that does this? (At the time of writing it appears not, but I wanted to verify.) Package Restore capability would be nice because then I don't have to include the (many) WiX files in git.
If not, what do I need to download from WiX? What do I need to modify so that the compiler knows where to find the binaries to build WiX projects?
You can download just the WiX Binaries .zip from http://wixtoolset.org/releases/ then you can modify your wixproj file and update the <WixToolPath></WixToolPath> element to point to your WixBinaries
The WiX documentation has an article that explains how: Integrating Wix Projects into your Daily Builds
There is an unofficial nuget package at WiX.Toolset.
However, note that this seems to only be applicable to the setup project itself (i.e. it cannot be used to fetch wix binaries for e.g. a class library assembly).

Rebuild WiX when custom action binary changes?

I have a hand-crafted MSBuild script that build my WiX based installer. The installer contains a custom action DLL as a <Binary> element. MSBuild thinks the MSI is still up to date when this DLL changes, although it rebuilds correctly when I change other files that are part of components. Is there some way to tell the Light task to look at additional dependencies?
Thanks.
Create a ProjectReference from your .wixproj to your custom action project and MSBuild will correctly detect the dependency and should cause the installer project to build again. Additionally, WiX v3.6+ has improved the rebuild checks so ensure you are using a new version of the WiX toolset as well. If you still see problems it could be a bug in the WiX toolset that would be great to fix.

Integrating Wix with MSBuild

we are looking to automate an MSI generation for a product we are developing. Currently we have MSBuild building out the source to a network location, this is fine for testing but when it comes to releasing the software we will need to wrap it in an MSI.
The software is all .Net bar 1 COM component that will need registered on each machine it gets installed to.
What I was wondering was how to integrate Wix with MSBuild so that a new wix script will get generated along with an MSI that is able to handle fresh and upgrade installs.
Any help with this is very much appreciated.
Thanks,
Brendan
Sure, there are tasks in MS Build that can do all you need to build an MSI from WiX. Can you integrate this on a build / integration server?
Newer builds of Wix actually include a file called "wix.targets", which should get you started.
Also check out these fine articles on the topic:
Building with Wix.Targets (by Heath Stewart)
Wix Target for MSBuild (by Willem Meints)
Automate Releases With MSBuild And Windows Installer XML (by Sayed Ibrahim Hashimi) (Web archive link for archived msdn magazine)
They cover the topic in much more detail and are extremely helpful to get started.
You should download and install Votive. This will create a Visual Studio project file which you can use with MSBuild to create a WiX-based MSI.
There is also a topic in the WiX manual about how to integrate with MSBuild called Using WiX with MSBuild.