Skip to content

Commit

Permalink
Add per-platform custom action support.
Browse files Browse the repository at this point in the history
  • Loading branch information
barnson committed Jul 4, 2020
1 parent 4e1ad5e commit 6d17a02
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 70 deletions.
4 changes: 2 additions & 2 deletions Dependency.wixext.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2016
# Visual Studio Version 16
VisualStudioVersion = 16.0.30204.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dependencyca", "src\ca\dependencyca.vcxproj", "{B86AF46C-0F90-49CC-923F-A800B088D015}"
EndProject
Expand Down
39 changes: 27 additions & 12 deletions src/ca/dependencyca.vcxproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->

<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props')" />
<Import Project="..\..\packages\WixToolset.WcaUtil.4.0.16\build\WixToolset.WcaUtil.props" Condition="Exists('..\..\packages\WixToolset.WcaUtil.4.0.16\build\WixToolset.WcaUtil.props')" />

<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand All @@ -14,48 +12,65 @@
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>

<PropertyGroup Label="Globals">
<ProjectGuid>{B86AF46C-0F90-49CC-923F-A800B088D015}</ProjectGuid>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<TargetName>dependencyca</TargetName>
<ProjectModuleDefinitionFile>wixdepca.def</ProjectModuleDefinitionFile>
<Description>WiX Toolset Dependency CustomAction</Description>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

<PropertyGroup>
<ProjectAdditionalLinkLibraries>msi.lib</ProjectAdditionalLinkLibraries>
</PropertyGroup>

<ItemGroup>
<ClCompile Include="dllmain.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="wixdepca.cpp" />
</ItemGroup>

<ItemGroup>
<ClInclude Include="precomp.h" />
</ItemGroup>

<ItemGroup>
<None Include="packages.config" />
<None Include="wixdepca.def" />
</ItemGroup>

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props'))" />
<Error Condition="!Exists('..\..\packages\WixToolset.WcaUtil.4.0.16\build\WixToolset.WcaUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.WcaUtil.4.0.16\build\WixToolset.WcaUtil.props'))" />
</Target>
</Project>
</Project>
1 change: 1 addition & 0 deletions src/ca/dependencyca.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
<None Include="wixdepca.def">
<Filter>Source Files</Filter>
</None>
<None Include="packages.config" />
</ItemGroup>
</Project>
23 changes: 2 additions & 21 deletions src/wixext/DependencyCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,17 +362,7 @@ private IComponentKeyPath ParseProvidesElement(Intermediate intermediate, Interm

if (PackageType.None == packageType)
{
// Reference the Check custom action to check for dependencies on the current provider.
if (Platform.ARM == this.Context.Platform)
{
// Ensure the ARM version of the CA is referenced.
this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyCheck_ARM");
}
else
{
// All other supported platforms use x86.
this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyCheck");
}
this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "DependencyCheck", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64);

// Generate registry rows for the provider using binder properties.
var keyProvides = String.Concat(DependencyCommon.RegistryRoot, key);
Expand Down Expand Up @@ -578,16 +568,7 @@ private void ParseRequiresRefElement(Intermediate intermediate, IntermediateSect

private void AddReferenceToWixDependencyRequire(IntermediateSection section, SourceLineNumber sourceLineNumbers)
{
if (Platform.ARM == this.Context.Platform)
{
// Ensure the ARM version of the CA is referenced.
this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyRequire_ARM");
}
else
{
// All other supported platforms use x86.
this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyRequire");
}
this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "DependencyRequire", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64);
}
}
}
13 changes: 8 additions & 5 deletions src/wixlib/DependencyExtension_Platform.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@


<Include xmlns="http://wixtoolset.org/schemas/v4/wxs">
<?include caSuffix.wxi ?>
<?include caDecor.wxi ?>

<Fragment>
<CustomAction Id="WixDependencyRequire$(var.Suffix)" BinaryKey="DependencyCA$(var.Suffix)" DllEntry="WixDependencyRequire" Execute="immediate" Return="check" SuppressModularization="yes"/>
<CustomAction Id="$(var.Prefix)DependencyRequire$(var.Suffix)" BinaryKey="DependencyCA$(var.Suffix)" DllEntry="WixDependencyRequire" Execute="immediate" Return="check" SuppressModularization="yes"/>
<InstallExecuteSequence>
<Custom Action="WixDependencyRequire$(var.Suffix)" Before="WixDependencyCheck$(var.Suffix)" Overridable="yes"><![CDATA[NOT DISABLEDEPENDENCYCHECK]]></Custom>
<Custom Action="$(var.Prefix)DependencyRequire$(var.Suffix)" Before="WixDependencyCheck$(var.Suffix)" Overridable="yes"><![CDATA[NOT DISABLEDEPENDENCYCHECK]]></Custom>
</InstallExecuteSequence>
<UIRef Id="WixDependencyErrors"/>
<PropertyRef Id="DISABLEDEPENDENCYCHECK"/>
</Fragment>

<Fragment>
<CustomAction Id="WixDependencyCheck$(var.Suffix)" BinaryKey="DependencyCA$(var.Suffix)" DllEntry="WixDependencyCheck" Execute="immediate" Return="check" SuppressModularization="yes"/>
<CustomAction Id="$(var.Prefix)DependencyCheck$(var.Suffix)" BinaryKey="DependencyCA$(var.Suffix)" DllEntry="WixDependencyCheck" Execute="immediate" Return="check" SuppressModularization="yes"/>
<InstallExecuteSequence>
<Custom Action="WixDependencyCheck$(var.Suffix)" Before="InstallInitialize" Overridable="yes"><![CDATA[(REMOVE OR MsiPatchRemovalList) AND NOT (UPGRADINGPRODUCTCODE OR IGNOREDEPENDENCIES="ALL")]]></Custom>
<Custom Action="$(var.Prefix)DependencyCheck$(var.Suffix)" Before="InstallInitialize" Overridable="yes"><![CDATA[(REMOVE OR MsiPatchRemovalList) AND NOT (UPGRADINGPRODUCTCODE OR IGNOREDEPENDENCIES="ALL")]]></Custom>
</InstallExecuteSequence>
<UIRef Id="WixDependencyErrors"/>
<PropertyRef Id="IGNOREDEPENDENCIES"/>
</Fragment>

<Fragment>
<Binary Id="DependencyCA$(var.Suffix)" SourceFile="!(bindpath.$(var.platform))dependencyca.dll"/>
</Fragment>
Expand Down
8 changes: 8 additions & 0 deletions src/wixlib/DependencyExtension_arm.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->


<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<?define platform=arm ?>
<?include DependencyExtension_Platform.wxi ?>
</Wix>
8 changes: 8 additions & 0 deletions src/wixlib/DependencyExtension_arm64.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->


<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<?define platform=arm64 ?>
<?include DependencyExtension_Platform.wxi ?>
</Wix>
8 changes: 8 additions & 0 deletions src/wixlib/DependencyExtension_x64.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->


<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<?define platform=x64 ?>
<?include DependencyExtension_Platform.wxi ?>
</Wix>
40 changes: 40 additions & 0 deletions src/wixlib/caDecor.wxi
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->


<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?ifdef Prefix ?>
<?undef Prefix ?>
<?endif ?>

<?define Prefix="Wix4" ?>

<?ifndef platform ?>
<?define platform="x86" ?>
<?endif ?>

<?if $(var.platform)="" ?>
<?undef platform ?>
<?define platform="x86" ?>
<?endif ?>

<?ifdef Suffix ?>
<?undef Suffix ?>
<?endif ?>

<?if $(var.platform)~="x86" ?>
<?define Suffix="_X86" ?>
<?endif ?>

<?if $(var.platform)~="x64" ?>
<?define Suffix="_X64" ?>
<?endif ?>

<?if $(var.platform)~="arm" ?>
<?define Suffix="_A32" ?>
<?endif ?>

<?if $(var.platform)~="arm64" ?>
<?define Suffix="_A64" ?>
<?endif ?>
</Include>
28 changes: 0 additions & 28 deletions src/wixlib/caSuffix.wxi

This file was deleted.

7 changes: 5 additions & 2 deletions src/wixlib/dependency.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<BindFiles>true</BindFiles>
<!-- <SuppressSpecificWarnings>1086</SuppressSpecificWarnings> -->
<SuppressSpecificWarnings>1086</SuppressSpecificWarnings>
<Cultures>en-us</Cultures>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ca\dependencyca.vcxproj" />
<ProjectReference Include="..\ca\dependencyca.vcxproj" Properties="Platform=ARM" />
<ProjectReference Include="..\ca\dependencyca.vcxproj" Properties="Platform=ARM64" />
<ProjectReference Include="..\ca\dependencyca.vcxproj" Properties="Platform=x86" />
<ProjectReference Include="..\ca\dependencyca.vcxproj" Properties="Platform=x64" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 6d17a02

Please sign in to comment.