Skip to content

Commit

Permalink
Adding ExecuteOnReinstall attribute for WiX extension SystemTools -> …
Browse files Browse the repository at this point in the history
…TemplateFile
  • Loading branch information
wojwal committed Sep 15, 2015
1 parent d2d8d58 commit b3d9cb3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* **Features**:
* Added `SERVICE_NAME` as an alternative property for specifying service name in Service_Change... calls - [@vladaver](https://github.com/vladaver).
* [#8](https://github.com/dblock/msiext/pull/8) - Added `Service_GetState` immediate custom action - [@vladaver](https://github.com/vladaver).
* [#21](https://github.com/dblock/msiext/pull/21) - Added `ExecuteOnReinstall` for SystemTools::TemplateFile - [@wojwal](https://github.com/wojwal).
* **Bugs**:
* [#9](https://github.com/dblock/msiext/issues/9) - Fixed build failures if WiX Toolset v3.7 or MSBuild Community Tasks are not installed - [@icnocop](https://github.com/icnocop).
* **Misc**:
Expand Down
5 changes: 4 additions & 1 deletion src/CustomActions/SystemTools/TemplateFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ enum ExecuteAttributes
ExecuteOnInstall = 1,
ExecuteOnUnInstall = 2,
// ExecuteOnRollback = 4,
// ExecuteOnReInstall = 8,
ExecuteOnReInstall = 8,
};

CA_API UINT __stdcall TemplateFiles_Immediate(MSIHANDLE hInstall)
Expand Down Expand Up @@ -47,10 +47,13 @@ CA_API UINT __stdcall TemplateFiles_Immediate(MSIHANDLE hInstall)
bool execute_per_component_install = (component_id.empty() || msiInstall.IsComponentInstalling(component_id));
// execute on uninstall
bool execute_per_component_uninstall = (component_id.empty() || msiInstall.IsComponentUnInstalling(component_id));
// execute on reinstall
bool execute_per_component_reinstall = (component_id.empty() || msiInstall.IsComponentReInstalling(component_id));

bool execute = execute_per_condition && (
(execute_per_component_install && (attributes & ExecuteOnInstall) && msiInstall.IsInstalling())
|| (execute_per_component_uninstall && (attributes & ExecuteOnUnInstall) && msiInstall.IsUnInstalling())
|| (execute_per_component_reinstall && (attributes & ExecuteOnReInstall) && msiInstall.IsReInstalling())
);

MSXML2::IXMLDOMNodePtr templatefile_node = combined_xml_document.AppendChild(L"TemplateFile", combined_xml_root);
Expand Down
5 changes: 5 additions & 0 deletions src/Framework/Msi/MsiInstall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,11 @@ bool MsiInstall::IsRollback()
return (TRUE == ::MsiGetMode(_h, MSIRUNMODE_ROLLBACK));
}

bool MsiInstall::IsReInstalling()
{
return EvaluateCondition(L"Installed AND NOT REMOVE~=\"ALL\"");
}

bool MsiInstall::IsUnInstalling()
{
//! \todo This has to be wrong for reinstall
Expand Down
2 changes: 2 additions & 0 deletions src/Framework/Msi/MsiInstall.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class MsiInstall
bool EvaluateCondition(const std::wstring& condition);
//! returns true if the product is being installed
bool IsInstalling();
//! returns true if the product is being reinstalled
bool IsReInstalling();
//! returns true if the product is being uninstalled
bool IsUnInstalling();
//! returns true if the current state is rollback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ enum TemplateFileAttributes
ExecuteOnInstall = 1,
ExecuteOnUnInstall = 2,
// ExecuteOnRollback = 4,
// ExecuteOnReInstall = 16,
ExecuteOnReInstall = 8,
};

private void ParseTemplateFileElement(string componentid, XmlElement node)
Expand Down Expand Up @@ -808,12 +808,12 @@ private void ParseTemplateFileElement(string componentid, XmlElement node)
attributes |= (int)TemplateFileAttributes.ExecuteOnUnInstall;
}
break;
//case "ExecuteOnReInstall":
// if (this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib) == YesNoType.Yes)
// {
// attributes |= (int)TemplateFileAttributes.ExecuteOnReInstall;
// }
// break;
case "ExecuteOnReInstall":
if (this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib) == YesNoType.Yes)
{
attributes |= (int)TemplateFileAttributes.ExecuteOnReInstall;
}
break;
//case "ExecuteOnRollback":
// if (this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib) == YesNoType.Yes)
// {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ TemplateFileProperty with a value.
<xs:documentation>Process the template file at uninstall time.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExecuteOnReInstall" use="optional" type="YesNoType">
<xs:annotation>
<xs:documentation>Process the template file at reinstall time.</xs:documentation>
</xs:annotation>
</xs:attribute>
<!--
<xs:attribute name="ExecuteOnRollback" use="optional" type="YesNoType">
<xs:annotation>
Expand Down

0 comments on commit b3d9cb3

Please sign in to comment.