diff options
Diffstat (limited to 'src/WixToolset.Core.Burn/Bundles/CreateContainerCommand.cs')
-rw-r--r-- | src/WixToolset.Core.Burn/Bundles/CreateContainerCommand.cs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/WixToolset.Core.Burn/Bundles/CreateContainerCommand.cs b/src/WixToolset.Core.Burn/Bundles/CreateContainerCommand.cs new file mode 100644 index 00000000..75379713 --- /dev/null +++ b/src/WixToolset.Core.Burn/Bundles/CreateContainerCommand.cs | |||
@@ -0,0 +1,68 @@ | |||
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.Collections.Generic; | ||
7 | using System.Diagnostics; | ||
8 | using System.IO; | ||
9 | using System.Linq; | ||
10 | using WixToolset.Core.Cab; | ||
11 | using WixToolset.Data; | ||
12 | using WixToolset.Data.Rows; | ||
13 | |||
14 | /// <summary> | ||
15 | /// Creates cabinet files. | ||
16 | /// </summary> | ||
17 | internal class CreateContainerCommand | ||
18 | { | ||
19 | public CompressionLevel DefaultCompressionLevel { private get; set; } | ||
20 | |||
21 | public IEnumerable<WixBundlePayloadRow> Payloads { private get; set; } | ||
22 | |||
23 | public string ManifestFile { private get; set; } | ||
24 | |||
25 | public string OutputPath { private get; set; } | ||
26 | |||
27 | public string Hash { get; private set; } | ||
28 | |||
29 | public long Size { get; private set; } | ||
30 | |||
31 | public void Execute() | ||
32 | { | ||
33 | int payloadCount = this.Payloads.Count(); // The number of embedded payloads | ||
34 | |||
35 | if (!String.IsNullOrEmpty(this.ManifestFile)) | ||
36 | { | ||
37 | ++payloadCount; | ||
38 | } | ||
39 | |||
40 | using (var cab = new WixCreateCab(Path.GetFileName(this.OutputPath), Path.GetDirectoryName(this.OutputPath), payloadCount, 0, 0, this.DefaultCompressionLevel)) | ||
41 | { | ||
42 | // If a manifest was provided always add it as "payload 0" to the container. | ||
43 | if (!String.IsNullOrEmpty(this.ManifestFile)) | ||
44 | { | ||
45 | cab.AddFile(this.ManifestFile, "0"); | ||
46 | } | ||
47 | |||
48 | foreach (WixBundlePayloadRow payload in this.Payloads) | ||
49 | { | ||
50 | Debug.Assert(PackagingType.Embedded == payload.Packaging); | ||
51 | |||
52 | Messaging.Instance.OnMessage(WixVerboses.LoadingPayload(payload.FullFileName)); | ||
53 | |||
54 | cab.AddFile(payload.FullFileName, payload.EmbeddedId); | ||
55 | } | ||
56 | |||
57 | cab.Complete(); | ||
58 | } | ||
59 | |||
60 | // Now that the container is created, set the outputs of the command. | ||
61 | FileInfo fileInfo = new FileInfo(this.OutputPath); | ||
62 | |||
63 | this.Hash = Common.GetFileHash(fileInfo.FullName); | ||
64 | |||
65 | this.Size = fileInfo.Length; | ||
66 | } | ||
67 | } | ||
68 | } | ||