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