WiX version from C# file - wix

All my .net applications take their version from one C# version file.
lets call it version.cs.
How can i make one WIX project set the version according to this file?
I saw :
How can I set the WiX installer version to the current build version?
but it cannot help me because I am wrapping several DLL and some of them may have the correct version and some not.
How can I Bind the version from C# file?

WiX has no support for this. You'd have to write some build automation to extract the version from the cs file and pass it to WiX's command line at build time.
Personally what I do is use build automation to own the build version and push it into both WiX and C#. Since I'm using TFS Team Build there are libraries already written ( TFSVersioning ) that do this for me.

Related

How to determine what WiX version that was used to create a wixproj

Quite simply, what the title says: I have some old source code with a WiX installer project in it. I'm trying to determine what Version of WiX was used to build it so I'm using the same version when I try to rebuild it.
If you open the wixproj file into a text editor (or unload/edit in Visual Studio), you will see (or should) the following property;
<ProductVersion>3.8</ProductVersion>
That is the only reference I could find to what I know is the version I am using.

Sample application for WiX bootstrapper for beginners

I'm very new to WiX based applications, and I need to create an MSI file where it has to check for .NET Framework 4.0 and SQL Server 2008. If they are not installed, I have to get them installed first and then have to install my application's EXE file and one more VBScript agent. It must be done like when you install WiX 3.7 setup (if we double click the setup file, it will show a UI as shown below!
Where do I start? Is there any step-by-step guide to develop this kind of application?
You'll need the following projects. They can be created from project templates in Visual Studio. Each of them would probably have separate tutorials that you might find with a Web search.
A WiX Setup project to build an .msi. The source files for such a project declare a WiX/Product. It could have conditions that check for .Net Framework4.0 and SQL Server 2008. If a check fails, installation of the .msi will fail, which is all that can be done in an .msi. The project would include your application .exe as a Component.
A WiX Bootstrapper project to build an .exe. The source files for such a project declare a WiX/Bundle. In the bundle is a Chain of installers, which would include .Net Framework4.0, SQL Server 2008, your .msi, and your VBScript Agent.
A WPF Library project to provide a BootstrapperApplication implementation with a custom UI for the bootstrapper project.
Your best bet is to consult the documentation, the WiX source code and various tutorials. Keep in the mind that tutorials might be out-of-date--in most cases WiX has gotten simpler with each version.

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

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.

Why does Mage.exe not generate a compatibleFrameworks attribute?

We are using Mage.exe to generate our application's manifests as part of our build process. Upon upgrading to .NET 4 we now find it generates an invalid manifest.
The reason is there isn't a compatibleFrameworks attribute being set in the application manifest which we generate every build.
Is there a way we can make Mage.exe add this element or should we only ever update existing manifests?
There is a separate copy of mage.exe built for .NET 4.0. Try using this copy from C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools (or ...\v7.1\Bin\NETFX 4.0 Tools depending on which SDK version you have installed).
I was actually having this same problem and using the mage.exe from NETFX 4.0 Tools fixed it for me.
Add this to your GenerateDeploymentManifest MSBuild task
TargetFrameworkMoniker=".NETFramework,Version=v4.0"
and that should fix it

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.