Skip to content

Instantly share code, notes, and snippets.

@dguder
Last active December 16, 2015 15:49
Show Gist options
  • Save dguder/5458583 to your computer and use it in GitHub Desktop.
Save dguder/5458583 to your computer and use it in GitHub Desktop.
Check-Installed-Files.build nant script to check if a msi installer contains all required files Based on discussion in WiX mailing list http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Wix-layout-tp704688.html
<?xml version="1.0" encoding="utf-8" ?>
<project name="check installer" default="check-installed-files" basedir="." xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd">
<description>
</description>
<property name="buildarea.dir" value="C:\path\to\buildarea" />
<property name="msitarget.dir" value="_installer" />
<property name="msi.file" value="ProductName.msi" />
<target name="extract-msi" description="extract">
<delete dir="${msitarget.dir}" />
<exec program="msiexec.exe" verbose="true">
<arg value="/a" />
<arg value="${msi.file}" />
<arg value="TARGETDIR=${path::get-full-path(msitarget.dir)}" />
<arg line="/qn INSTALL=ALL" />
</exec>
</target>
<target name="check-installed-files" description="check">
<property name="check.dir" value="${path::combine(msitarget.dir, 'Program Files\ProductName')}" />
<property name="missingfiles" value="false" />
<fileset id="files.deployed" basedir="${buildarea.dir}">
<include name="**" />
<exclude name="**\SomeFileToExclude.dll" />
</fileset>
<foreach item="File" property="filename">
<in>
<items refid="files.deployed" />
</in>
<do>
<property name="filepath" value="${string::replace(filename, buildarea.dir + '\', '')}" />
<if test="${not file::exists(path::combine(check.dir, filepath))}" >
<echo message="File '${filepath}' is missing in installer" level="Error" />
<property name="missingfiles" value="true" />
</if>
</do>
</foreach>
<if test="${missingfiles}">
<echo message="Directories used:" />
<echo message="Source files in '${path::get-full-path(buildarea.dir)}'" />
<echo message="Msi files in '${path::get-full-path(check.dir)}'" />
<fail message="One or more files are missing in installer." />
</if>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment