diff options
Diffstat (limited to 'src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExtensionManifestCommand.cs')
-rw-r--r-- | src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExtensionManifestCommand.cs | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExtensionManifestCommand.cs b/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExtensionManifestCommand.cs new file mode 100644 index 00000000..e587413e --- /dev/null +++ b/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExtensionManifestCommand.cs | |||
@@ -0,0 +1,99 @@ | |||
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 | |||
3 | namespace WixToolset.Core.Burn.Bundles | ||
4 | { | ||
5 | using System; | ||
6 | using System.Globalization; | ||
7 | using System.IO; | ||
8 | using System.Text; | ||
9 | using System.Xml; | ||
10 | using WixToolset.Data; | ||
11 | using WixToolset.Data.Burn; | ||
12 | using WixToolset.Data.Symbols; | ||
13 | |||
14 | internal class CreateBundleExtensionManifestCommand | ||
15 | { | ||
16 | public CreateBundleExtensionManifestCommand(IntermediateSection section, WixBundleSymbol bundleSymbol, int lastUXPayloadIndex, string intermediateFolder, IInternalBurnBackendHelper internalBurnBackendHelper) | ||
17 | { | ||
18 | this.Section = section; | ||
19 | this.BundleSymbol = bundleSymbol; | ||
20 | this.LastUXPayloadIndex = lastUXPayloadIndex; | ||
21 | this.IntermediateFolder = intermediateFolder; | ||
22 | this.InternalBurnBackendHelper = internalBurnBackendHelper; | ||
23 | } | ||
24 | |||
25 | private IntermediateSection Section { get; } | ||
26 | |||
27 | private WixBundleSymbol BundleSymbol { get; } | ||
28 | |||
29 | private IInternalBurnBackendHelper InternalBurnBackendHelper { get; } | ||
30 | |||
31 | private int LastUXPayloadIndex { get; } | ||
32 | |||
33 | private string IntermediateFolder { get; } | ||
34 | |||
35 | public WixBundlePayloadSymbol BundleExtensionManifestPayloadRow { get; private set; } | ||
36 | |||
37 | public string OutputPath { get; private set; } | ||
38 | |||
39 | public void Execute() | ||
40 | { | ||
41 | this.OutputPath = this.CreateBundleExtensionManifest(); | ||
42 | |||
43 | this.BundleExtensionManifestPayloadRow = this.CreateBundleExtensionManifestPayloadRow(this.OutputPath); | ||
44 | } | ||
45 | |||
46 | private string CreateBundleExtensionManifest() | ||
47 | { | ||
48 | var path = Path.Combine(this.IntermediateFolder, "wix-bextdata.xml"); | ||
49 | |||
50 | Directory.CreateDirectory(Path.GetDirectoryName(path)); | ||
51 | |||
52 | using (var writer = new XmlTextWriter(path, Encoding.Unicode)) | ||
53 | { | ||
54 | writer.Formatting = Formatting.Indented; | ||
55 | writer.WriteStartDocument(); | ||
56 | writer.WriteStartElement("BundleExtensionData", BurnCommon.BundleExtensionDataNamespace); | ||
57 | |||
58 | this.InternalBurnBackendHelper.WriteBundleExtensionData(writer); | ||
59 | |||
60 | writer.WriteEndElement(); | ||
61 | writer.WriteEndDocument(); | ||
62 | } | ||
63 | |||
64 | return path; | ||
65 | } | ||
66 | |||
67 | private WixBundlePayloadSymbol CreateBundleExtensionManifestPayloadRow(string bextManifestPath) | ||
68 | { | ||
69 | var generatedId = this.InternalBurnBackendHelper.GenerateIdentifier("ux", BurnCommon.BundleExtensionDataFileName); | ||
70 | |||
71 | this.Section.AddSymbol(new WixGroupSymbol(this.BundleSymbol.SourceLineNumbers) | ||
72 | { | ||
73 | ParentType = ComplexReferenceParentType.Container, | ||
74 | ParentId = BurnConstants.BurnUXContainerName, | ||
75 | ChildType = ComplexReferenceChildType.Payload, | ||
76 | ChildId = generatedId | ||
77 | }); | ||
78 | |||
79 | var symbol = this.Section.AddSymbol(new WixBundlePayloadSymbol(this.BundleSymbol.SourceLineNumbers, new Identifier(AccessModifier.Section, generatedId)) | ||
80 | { | ||
81 | Name = BurnCommon.BundleExtensionDataFileName, | ||
82 | SourceFile = new IntermediateFieldPathValue { Path = bextManifestPath }, | ||
83 | Compressed = true, | ||
84 | UnresolvedSourceFile = bextManifestPath, | ||
85 | ContainerRef = BurnConstants.BurnUXContainerName, | ||
86 | EmbeddedId = String.Format(CultureInfo.InvariantCulture, BurnCommon.BurnUXContainerEmbeddedIdFormat, this.LastUXPayloadIndex), | ||
87 | Packaging = PackagingType.Embedded, | ||
88 | }); | ||
89 | |||
90 | var fileInfo = new FileInfo(bextManifestPath); | ||
91 | |||
92 | symbol.FileSize = (int)fileInfo.Length; | ||
93 | |||
94 | symbol.Hash = BundleHashAlgorithm.Hash(fileInfo); | ||
95 | |||
96 | return symbol; | ||
97 | } | ||
98 | } | ||
99 | } | ||