<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
	<Product
		Id="*"
		Name="Graphviz"
		Language="1033"
		Version="@GRAPHVIZ_VERSION_MAJOR@.@GRAPHVIZ_VERSION_MINOR@.@GRAPHVIZ_VERSION_BUILD@.@GRAPHVIZ_VERSION_REVISION@"
		Manufacturer="AT&amp;T"
		UpgradeCode="AF1FC8C2-70F0-449C-AF20-B43545CC68D1">
		<!-- Product Id is autogenerated, so every build is a "major upgrade" -->

		<Package
			Description="AT&amp;T Graphviz"
			Comments="AT&amp;T Graphviz - Graph Visualization Software"
			Manufacturer="AT&amp;T"
			InstallerVersion="200"
			Compressed="yes" />

		<Property Id="ALLUSERS" Value="1" />
		<Property Id="ARPCOMMENTS" Value="AT&amp;T Graphviz - Graph Visualization Software" />
		<Property Id="ARPHELPLINK" Value="http://www.graphviz.org/" />
		<Property Id="ARPURLUPDATEINFO" Value="http://www.graphviz.org/Download_windows.php" />

		<Condition Message="Windows XP, Windows Server 2003 or later is required.">
			<![CDATA[VersionNT >= 501]]>
		</Condition>
		<Condition Message=".NET Framework 2.0 or later is required.">
			<![CDATA[MsiNetAssemblySupport >= "2.0.50727"]]>
		</Condition>	
		
		<UIRef Id="WixUI_Mondo" />

		<Media Id="1" Cabinet="graphviz.cab" EmbedCab="yes" />

		<Upgrade Id="AF1FC8C2-70F0-449C-AF20-B43545CC68D1">
			<!-- don't install over same or newer versions -->
			<UpgradeVersion
				Minimum="@GRAPHVIZ_VERSION_MAJOR@.@GRAPHVIZ_VERSION_MINOR@.@GRAPHVIZ_VERSION_BUILD@.@GRAPHVIZ_VERSION_REVISION@"
				IncludeMinimum="yes"
				OnlyDetect="yes"
				Language="1033"
				Property="NEWPRODUCTFOUND" />
			<!-- install over all older versions -->
			<UpgradeVersion
				Minimum="0.0.0.0"
				IncludeMinimum="yes"
				Maximum="@GRAPHVIZ_VERSION_MAJOR@.@GRAPHVIZ_VERSION_MINOR@.@GRAPHVIZ_VERSION_BUILD@.@GRAPHVIZ_VERSION_REVISION@"
				IncludeMaximum="no"
				Language="1033"
				Property="UPGRADEFOUND" />
		</Upgrade>

		<Directory Id="TARGETDIR" Name="SourceDir">
			<Directory Id="ProgramFilesFolder">
				<Directory Id="ApplicationProgramFilesFolder" Name="Graphviz">
					<!-- bin, etc, include, lib and share are referenced by the directories in the heated wxs -->
					<Directory Id="bin" Name="bin">
						<!-- need to remove the config file when uninstalling -->
						<Component Id="config" Guid="DAD3E382-59B2-429A-9292-0C28A12783C3">
							<RemoveFile Id="config" Name="config" On="uninstall" />
						</Component>
						<!-- viewer application sourced from graphviz.csproj build directory, include shortcuts in the start menu and desktop -->
						<Component Id="Graphviz.exe" Guid="25FE550B-3D8B-435B-AB35-553D2628171D">
							<File Id="Graphviz.exe" Name="Graphviz.exe" KeyPath="yes" Source="x86\Release\Graphviz.exe">
								<Shortcut Id="ApplicationProgramMenu" Name="Graphviz" Directory="ApplicationProgramMenuFolder" Icon="Graphviz.ico" Advertise="yes" />
								<Shortcut Id="ApplicationDesktop" Name="Graphviz" Directory="DesktopFolder" Icon="Graphviz.ico" Advertise="yes" />
							</File>
							<ProgId Id="Graphviz.Graph" Description="Graphviz Graph" Icon="Graphviz.exe" IconIndex="2">
								<Extension Id="gv" ContentType="text/vnd.graphviz">
									<Verb Id="open" Argument="&quot;%1&quot;" Command="Open" TargetFile="Graphviz.exe" />
								</Extension>
							</ProgId>
							<ProgId Id="Graphviz.Dot" Description="Graphviz Graph" Icon="Graphviz.exe" IconIndex="1">
								<Extension Id="dot">
									<Verb Id="open" Argument="&quot;%1&quot;" Command="Open" TargetFile="Graphviz.exe" />
								</Extension>
							</ProgId>
							<RemoveFolder Id="ApplicationProgramMenuFolder" Directory="ApplicationProgramMenuFolder" On="uninstall" />
						</Component>
						<Component Id="attributes.xml" Guid="7740171C-8A24-4720-9168-87575F6EF963">
							<File Id="attributes.xml" Name="attributes.xml" KeyPath="yes" Source="..\..\doc\schema\attributes.xml" />
						</Component>
					</Directory>
					<Directory Id="etc" Name="etc" />
					<Directory Id="include" Name="include" />
					<Directory Id="lib" Name="lib" />
					<Directory Id="share" Name="share" />
				</Directory>
			</Directory>
			<Directory Id="ProgramMenuFolder">
				<Directory Id="ApplicationProgramMenuFolder" Name="Graphviz" />
			</Directory>
			<Directory Id="DesktopFolder" />
		</Directory>

		<!-- icon for advertised shortcut, doesn't actually appear in installed file system -->
		<Icon Id="Graphviz.ico" SourceFile="Graphviz.ico" />
		
		<Feature Id="cli" Title="Command Line Tools and Libraries" Level="1">
			<!-- refer to component groups in the heated wxs -->
			<ComponentGroupRef Id="etc" />
			<ComponentGroupRef Id="bin" />
			<ComponentGroupRef Id="include" />
			<ComponentGroupRef Id="lib" />
			<ComponentGroupRef Id="share" />
			<ComponentRef Id="config" />
		</Feature>
		<Feature Id="gui" Title="Viewer Application" Level="1">
			<!-- refer to the viewer application -->
			<ComponentRef Id="Graphviz.exe" />
			<ComponentRef Id="attributes.xml"/>
		</Feature>

		<CustomAction Id="PreventDowngrading" Error="Same or newer version already installed." />
		<CustomAction Id="ConfigurePlugins" FileKey="dot.exe" ExeCommand="-c" Execute="deferred"/>

		<InstallExecuteSequence>
			<Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
			<!-- scan for plugins and save into config file when installing, reinstalling or repairing, uninstall will remove this file -->
			<Custom Action="ConfigurePlugins" After="InstallFiles">NOT(REMOVE="ALL")</Custom>
			<RemoveExistingProducts After="InstallFinalize" />
		</InstallExecuteSequence>

		<InstallUISequence>
			<Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
		</InstallUISequence>
	</Product>
</Wix>
