aboutsummaryrefslogtreecommitdiff
path: root/src/wixext
diff options
context:
space:
mode:
Diffstat (limited to 'src/wixext')
-rw-r--r--src/wixext/DirectXDecompiler.cs70
-rw-r--r--src/wixext/DirectXExtensionData.cs34
-rw-r--r--src/wixext/WixDirectXExtension.csproj31
3 files changed, 135 insertions, 0 deletions
diff --git a/src/wixext/DirectXDecompiler.cs b/src/wixext/DirectXDecompiler.cs
new file mode 100644
index 00000000..c8056c12
--- /dev/null
+++ b/src/wixext/DirectXDecompiler.cs
@@ -0,0 +1,70 @@
1// 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.
2
3namespace WixToolset.Extensions
4{
5 using System;
6 using System.Text;
7 using WixToolset.Data;
8 using WixToolset.Extensibility;
9 using Wix = WixToolset.Data.Serialize;
10
11 /// <summary>
12 /// The WiX Toolset DirectX Extension.
13 /// </summary>
14 public sealed class DirectXDecompiler : DecompilerExtension
15 {
16 /// <summary>
17 /// Get the extensions library to be removed.
18 /// </summary>
19 /// <param name="tableDefinitions">Table definitions for library.</param>
20 /// <returns>Library to remove from decompiled output.</returns>
21 public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions)
22 {
23 return DirectXExtensionData.GetExtensionLibrary(tableDefinitions);
24 }
25
26 /// <summary>
27 /// Called at the beginning of the decompilation of a database.
28 /// </summary>
29 /// <param name="tables">The collection of all tables.</param>
30 public override void Initialize(TableIndexedCollection tables)
31 {
32 Table propertyTable = tables["Property"];
33
34 if (null != propertyTable)
35 {
36 foreach (Row row in propertyTable.Rows)
37 {
38 if ("SecureCustomProperties" == row[0].ToString())
39 {
40 // if we've referenced any of the DirectX properties, add
41 // a PropertyRef to pick up the CA from the extension and then remove
42 // it from the SecureCustomExtensions property so we don't get duplicates
43 StringBuilder remainingProperties = new StringBuilder();
44 string[] secureCustomProperties = row[1].ToString().Split(';');
45 foreach (string property in secureCustomProperties)
46 {
47 if (property.StartsWith("WIX_DIRECTX_"))
48 {
49 Wix.PropertyRef propertyRef = new Wix.PropertyRef();
50 propertyRef.Id = property;
51 this.Core.RootElement.AddChild(propertyRef);
52 }
53 else
54 {
55 if (0 < remainingProperties.Length)
56 {
57 remainingProperties.Append(";");
58 }
59 remainingProperties.Append(property);
60 }
61 }
62
63 row[1] = remainingProperties.ToString();
64 break;
65 }
66 }
67 }
68 }
69 }
70}
diff --git a/src/wixext/DirectXExtensionData.cs b/src/wixext/DirectXExtensionData.cs
new file mode 100644
index 00000000..828b087d
--- /dev/null
+++ b/src/wixext/DirectXExtensionData.cs
@@ -0,0 +1,34 @@
1// 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.
2
3namespace WixToolset.Extensions
4{
5 using System;
6 using System.Reflection;
7 using WixToolset.Data;
8 using WixToolset.Extensibility;
9
10 /// <summary>
11 /// The WiX Toolset DirectX Extension.
12 /// </summary>
13 public sealed class DirectXExtensionData : ExtensionData
14 {
15 /// <summary>
16 /// Gets the library associated with this extension.
17 /// </summary>
18 /// <param name="tableDefinitions">The table definitions to use while loading the library.</param>
19 /// <returns>The loaded library.</returns>
20 public override Library GetLibrary(TableDefinitionCollection tableDefinitions)
21 {
22 return DirectXExtensionData.GetExtensionLibrary(tableDefinitions);
23 }
24
25 /// <summary>
26 /// Internal mechanism to access the extension's library.
27 /// </summary>
28 /// <returns>Extension's library.</returns>
29 internal static Library GetExtensionLibrary(TableDefinitionCollection tableDefinitions)
30 {
31 return ExtensionData.LoadLibraryHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.DirectX.wixlib", tableDefinitions);
32 }
33 }
34}
diff --git a/src/wixext/WixDirectXExtension.csproj b/src/wixext/WixDirectXExtension.csproj
new file mode 100644
index 00000000..577d36f3
--- /dev/null
+++ b/src/wixext/WixDirectXExtension.csproj
@@ -0,0 +1,31 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3
4
5<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
6 <PropertyGroup>
7 <ProjectGuid>{6182DBCA-146A-4F37-8406-3139BBE04636}</ProjectGuid>
8 <AssemblyName>WixDirectXExtension</AssemblyName>
9 <OutputType>Library</OutputType>
10 <RootNamespace>WixToolset.Extensions</RootNamespace>
11 </PropertyGroup>
12 <ItemGroup>
13 <Compile Include="AssemblyInfo.cs" />
14 <Compile Include="DirectXDecompiler.cs" />
15 <Compile Include="DirectXExtensionData.cs" />
16 <EmbeddedResource Include="$(OutputPath)\DirectX.wixlib">
17 <Link>Data\DirectX.wixlib</Link>
18 </EmbeddedResource>
19 </ItemGroup>
20 <ItemGroup>
21 <Reference Include="System" />
22 <Reference Include="System.Xml" />
23 <ProjectReference Include="..\..\..\libs\WixToolset.Data\WixToolset.Data.csproj" />
24 <ProjectReference Include="..\..\..\libs\WixToolset.Extensibility\WixToolset.Extensibility.csproj" />
25 <ProjectReference Include="..\..\..\tools\wix\Wix.csproj" />
26 <ProjectReference Include="..\wixlib\DirectXExtension.wixproj">
27 <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
28 </ProjectReference>
29 </ItemGroup>
30 <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), wix.proj))\tools\WixBuild.targets" />
31</Project>