diff options
Diffstat (limited to 'src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs')
| -rw-r--r-- | src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs b/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs deleted file mode 100644 index 95805658..00000000 --- a/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs +++ /dev/null | |||
| @@ -1,155 +0,0 @@ | |||
| 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 WixBinPath = Path.GetDirectoryName(new Uri(typeof(WixBuild).Assembly.CodeBase).AbsolutePath) + "\\"; | ||
| 18 | private static readonly string WixTargetsPath = Path.Combine(WixBinPath, "wix.targets"); | ||
| 19 | |||
| 20 | [Fact] | ||
| 21 | public void CanBuildHeatFilePackage() | ||
| 22 | { | ||
| 23 | var projectPath = TestData.Get(@"TestData\HeatFilePackage\HeatFilePackage.wixproj"); | ||
| 24 | |||
| 25 | using (var fs = new DisposableFileSystem()) | ||
| 26 | { | ||
| 27 | var baseFolder = fs.GetFolder(); | ||
| 28 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 29 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
| 30 | |||
| 31 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
| 32 | { | ||
| 33 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
| 34 | $"-p:WixBinDir={WixBinPath}", | ||
| 35 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
| 36 | $"-p:OutputPath={binFolder}" | ||
| 37 | }); | ||
| 38 | result.AssertSuccess(); | ||
| 39 | |||
| 40 | var heatCommandLines = result.Output.Where(line => line.TrimStart().StartsWith("heat.exe file")); | ||
| 41 | Assert.Single(heatCommandLines); | ||
| 42 | |||
| 43 | var warnings = result.Output.Where(line => line.Contains(": warning")); | ||
| 44 | Assert.Empty(warnings); | ||
| 45 | |||
| 46 | var generatedFilePath = Path.Combine(intermediateFolder, @"_ProductComponents_INSTALLFOLDER_HeatFilePackage.wixproj_file.wxs"); | ||
| 47 | Assert.True(File.Exists(generatedFilePath)); | ||
| 48 | |||
| 49 | var generatedContents = File.ReadAllText(generatedFilePath); | ||
| 50 | var testXml = generatedContents.GetTestXml(); | ||
| 51 | Assert.Equal(@"<Wix>" + | ||
| 52 | "<Fragment>" + | ||
| 53 | "<DirectoryRef Id='INSTALLFOLDER'>" + | ||
| 54 | "<Component Id='HeatFilePackage.wixproj' Guid='*'>" + | ||
| 55 | "<File Id='HeatFilePackage.wixproj' KeyPath='yes' Source='SourceDir\\HeatFilePackage.wixproj' />" + | ||
| 56 | "</Component>" + | ||
| 57 | "</DirectoryRef>" + | ||
| 58 | "</Fragment>" + | ||
| 59 | "<Fragment>" + | ||
| 60 | "<ComponentGroup Id='ProductComponents'>" + | ||
| 61 | "<ComponentRef Id='HeatFilePackage.wixproj' />" + | ||
| 62 | "</ComponentGroup>" + | ||
| 63 | "</Fragment>" + | ||
| 64 | "</Wix>", testXml); | ||
| 65 | |||
| 66 | var pdbPath = Path.Combine(binFolder, "HeatFilePackage.wixpdb"); | ||
| 67 | Assert.True(File.Exists(pdbPath)); | ||
| 68 | |||
| 69 | var intermediate = Intermediate.Load(pdbPath); | ||
| 70 | var section = intermediate.Sections.Single(); | ||
| 71 | |||
| 72 | var fileTuple = section.Tuples.OfType<FileTuple>().Single(); | ||
| 73 | Assert.Equal(@"SourceDir\HeatFilePackage.wixproj", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | [Fact] | ||
| 78 | public void CanBuildHeatFileWithMultipleFilesPackage() | ||
| 79 | { | ||
| 80 | var projectPath = TestData.Get(@"TestData\HeatFileMultpleFilesSameFileName\HeatFileMultpleFilesSameFileName.wixproj"); | ||
| 81 | |||
| 82 | using (var fs = new DisposableFileSystem()) | ||
| 83 | { | ||
| 84 | var baseFolder = fs.GetFolder(); | ||
| 85 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 86 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
| 87 | |||
| 88 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
| 89 | { | ||
| 90 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
| 91 | $"-p:WixBinDir={WixBinPath}", | ||
| 92 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
| 93 | $"-p:OutputPath={binFolder}" | ||
| 94 | }); | ||
| 95 | result.AssertSuccess(); | ||
| 96 | |||
| 97 | var heatCommandLines = result.Output.Where(line => line.TrimStart().StartsWith("heat.exe file")); | ||
| 98 | Assert.Equal(2, heatCommandLines.Count()); | ||
| 99 | |||
| 100 | var warnings = result.Output.Where(line => line.Contains(": warning")); | ||
| 101 | Assert.Empty(warnings); | ||
| 102 | |||
| 103 | var generatedFilePath = Path.Combine(intermediateFolder, @"_TxtProductComponents_INSTALLFOLDER_MyProgram.txt_file.wxs"); | ||
| 104 | Assert.True(File.Exists(generatedFilePath)); | ||
| 105 | |||
| 106 | var generatedContents = File.ReadAllText(generatedFilePath); | ||
| 107 | var testXml = generatedContents.GetTestXml(); | ||
| 108 | Assert.Equal("<Wix>" + | ||
| 109 | "<Fragment>" + | ||
| 110 | "<DirectoryRef Id='INSTALLFOLDER'>" + | ||
| 111 | "<Component Id='MyProgram.txt' Guid='*'>" + | ||
| 112 | @"<File Id='MyProgram.txt' KeyPath='yes' Source='SourceDir\MyProgram.txt' />" + | ||
| 113 | "</Component>" + | ||
| 114 | "</DirectoryRef>" + | ||
| 115 | "</Fragment>" + | ||
| 116 | "<Fragment>" + | ||
| 117 | "<ComponentGroup Id='TxtProductComponents'>" + | ||
| 118 | "<ComponentRef Id='MyProgram.txt' />" + | ||
| 119 | "</ComponentGroup>" + | ||
| 120 | "</Fragment>" + | ||
| 121 | "</Wix>", testXml); | ||
| 122 | |||
| 123 | generatedFilePath = Path.Combine(intermediateFolder, @"_JsonProductComponents_INSTALLFOLDER_MyProgram.json_file.wxs"); | ||
| 124 | Assert.True(File.Exists(generatedFilePath)); | ||
| 125 | |||
| 126 | generatedContents = File.ReadAllText(generatedFilePath); | ||
| 127 | testXml = generatedContents.GetTestXml(); | ||
| 128 | Assert.Equal("<Wix>" + | ||
| 129 | "<Fragment>" + | ||
| 130 | "<DirectoryRef Id='INSTALLFOLDER'>" + | ||
| 131 | "<Component Id='MyProgram.json' Guid='*'>" + | ||
| 132 | @"<File Id='MyProgram.json' KeyPath='yes' Source='SourceDir\MyProgram.json' />" + | ||
| 133 | "</Component>" + | ||
| 134 | "</DirectoryRef>" + | ||
| 135 | "</Fragment>" + | ||
| 136 | "<Fragment>" + | ||
| 137 | "<ComponentGroup Id='JsonProductComponents'>" + | ||
| 138 | "<ComponentRef Id='MyProgram.json' />" + | ||
| 139 | "</ComponentGroup>" + | ||
| 140 | "</Fragment>" + | ||
| 141 | "</Wix>", testXml); | ||
| 142 | |||
| 143 | var pdbPath = Path.Combine(binFolder, "HeatFileMultpleFilesSameFileName.wixpdb"); | ||
| 144 | Assert.True(File.Exists(pdbPath)); | ||
| 145 | |||
| 146 | var intermediate = Intermediate.Load(pdbPath); | ||
| 147 | var section = intermediate.Sections.Single(); | ||
| 148 | |||
| 149 | var fileTuples = section.Tuples.OfType<FileTuple>().ToArray(); | ||
| 150 | Assert.Equal(@"SourceDir\MyProgram.txt", fileTuples[0][FileTupleFields.Source].PreviousValue.AsPath().Path); | ||
| 151 | Assert.Equal(@"SourceDir\MyProgram.json", fileTuples[1][FileTupleFields.Source].PreviousValue.AsPath().Path); | ||
| 152 | } | ||
| 153 | } | ||
| 154 | } | ||
| 155 | } | ||
