diff options
Diffstat (limited to 'src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs')
-rw-r--r-- | src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs b/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs new file mode 100644 index 00000000..de78c0bc --- /dev/null +++ b/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs | |||
@@ -0,0 +1,75 @@ | |||
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 WixToolsetTest.BuildTasks | ||
4 | { | ||
5 | using System; | ||
6 | using System.IO; | ||
7 | using System.Linq; | ||
8 | using WixBuildTools.TestSupport; | ||
9 | using WixToolset.BuildTasks; | ||
10 | using WixToolset.Core.TestPackage; | ||
11 | using WixToolset.Data; | ||
12 | using WixToolset.Data.Tuples; | ||
13 | using Xunit; | ||
14 | |||
15 | public class MsbuildHeatFixture | ||
16 | { | ||
17 | private static readonly string WixTargetsPath = Path.Combine(Path.GetDirectoryName(new Uri(typeof(HeatTask).Assembly.CodeBase).AbsolutePath), "wix.targets"); | ||
18 | |||
19 | [Fact] | ||
20 | public void CanBuildHeatFilePackage() | ||
21 | { | ||
22 | var projectPath = TestData.Get(@"TestData\HeatFilePackage\HeatFilePackage.wixproj"); | ||
23 | |||
24 | using (var fs = new DisposableFileSystem()) | ||
25 | { | ||
26 | var baseFolder = fs.GetFolder(); | ||
27 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
28 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
29 | |||
30 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
31 | { | ||
32 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
33 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
34 | $"-p:OutputPath={binFolder}" | ||
35 | }); | ||
36 | result.AssertSuccess(); | ||
37 | |||
38 | var heatCommandLines = result.Output.Where(line => line.TrimStart().StartsWith("heat.exe file")); | ||
39 | Assert.Single(heatCommandLines); | ||
40 | |||
41 | var warnings = result.Output.Where(line => line.Contains(": warning")); | ||
42 | Assert.Empty(warnings); | ||
43 | |||
44 | var generatedFilePath = Path.Combine(intermediateFolder, @"_HeatFilePackage_file.wxs"); | ||
45 | Assert.True(File.Exists(generatedFilePath)); | ||
46 | |||
47 | var generatedContents = File.ReadAllText(generatedFilePath); | ||
48 | var testXml = generatedContents.GetTestXml(); | ||
49 | Assert.Equal(@"<Wix>" + | ||
50 | "<Fragment>" + | ||
51 | "<DirectoryRef Id='INSTALLFOLDER'>" + | ||
52 | "<Component Id='HeatFilePackage.wixproj' Guid='*'>" + | ||
53 | "<File Id='HeatFilePackage.wixproj' KeyPath='yes' Source='SourceDir\\HeatFilePackage.wixproj' />" + | ||
54 | "</Component>" + | ||
55 | "</DirectoryRef>" + | ||
56 | "</Fragment>" + | ||
57 | "<Fragment>" + | ||
58 | "<ComponentGroup Id='ProductComponents'>" + | ||
59 | "<ComponentRef Id='HeatFilePackage.wixproj' />" + | ||
60 | "</ComponentGroup>" + | ||
61 | "</Fragment>" + | ||
62 | "</Wix>", testXml); | ||
63 | |||
64 | var pdbPath = Path.Combine(binFolder, "HeatFilePackage.wixpdb"); | ||
65 | Assert.True(File.Exists(pdbPath)); | ||
66 | |||
67 | var intermediate = Intermediate.Load(pdbPath); | ||
68 | var section = intermediate.Sections.Single(); | ||
69 | |||
70 | var fileTuple = section.Tuples.OfType<FileTuple>().Single(); | ||
71 | Assert.Equal(@"SourceDir\HeatFilePackage.wixproj", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); | ||
72 | } | ||
73 | } | ||
74 | } | ||
75 | } | ||