| 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.CoreIntegration |
| 4 | { |
| 5 | using System.IO; |
| 6 | using WixInternal.TestSupport; |
| 7 | using WixInternal.Core.TestPackage; |
| 8 | using WixToolset.Data; |
| 9 | using Xunit; |
| 10 | using System.Linq; |
| 11 | using WixToolset.Data.Symbols; |
| 12 | |
| 13 | public class AssemblyFixture |
| 14 | { |
| 15 | [Fact] |
| 16 | public void CanBuildWithAssembly() |
| 17 | { |
| 18 | var folder = TestData.Get(@"TestData", "Assembly"); |
| 19 | |
| 20 | using (var fs = new DisposableFileSystem()) |
| 21 | { |
| 22 | var baseFolder = fs.GetFolder(); |
| 23 | var msiPath = Path.Combine(baseFolder, "bin", "test.msi"); |
| 24 | |
| 25 | var result = WixRunner.Execute(new[] |
| 26 | { |
| 27 | "build", |
| 28 | Path.Combine(folder, "Package.wxs"), |
| 29 | Path.Combine(folder, "PackageComponents.wxs"), |
| 30 | "-loc", Path.Combine(folder, "Package.en-us.wxl"), |
| 31 | "-bindpath", Path.Combine(folder, "data"), |
| 32 | "-intermediateFolder", Path.Combine(baseFolder, "obj"), |
| 33 | "-o", msiPath |
| 34 | }); |
| 35 | |
| 36 | result.AssertSuccess(); |
| 37 | |
| 38 | Assert.True(File.Exists(Path.Combine(baseFolder, "bin", "test.msi"))); |
| 39 | Assert.True(File.Exists(Path.Combine(baseFolder, "bin", "test.wixpdb"))); |
| 40 | Assert.True(File.Exists(Path.Combine(baseFolder, "bin", "PFiles", "AssemblyMsiPackage", "candle.exe"))); |
| 41 | |
| 42 | var intermediate = Intermediate.Load(Path.Combine(baseFolder, "bin", "test.wixpdb")); |
| 43 | var section = intermediate.Sections.Single(); |
| 44 | |
| 45 | var fileSymbol = section.Symbols.OfType<FileSymbol>().Single(); |
| 46 | WixAssert.StringEqual(Path.Combine(folder, "data", "candle.exe"), fileSymbol[FileSymbolFields.Source].AsPath().Path); |
| 47 | WixAssert.StringEqual("candle.exe", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path); |
| 48 | |
| 49 | var msiAssemblyNameSymbols = section.Symbols.OfType<MsiAssemblyNameSymbol>(); |
| 50 | WixAssert.CompareLineByLine(new[] |
| 51 | { |
| 52 | "culture = neutral", |
| 53 | "fileVersion = 3.11.11810.0", |
| 54 | "name = candle", |
| 55 | "processorArchitecture = x86", |
| 56 | "publicKeyToken = 256B3414DFA97718", |
| 57 | "version = 3.0.0.0" |
| 58 | }, msiAssemblyNameSymbols.OrderBy(a => a.Name).Select(a => a.Name + " = " + a.Value).ToArray()); |
| 59 | |
| 60 | var rows = Query.QueryDatabase(msiPath, new[] { "MsiAssembly", "MsiAssemblyName" }); |
| 61 | WixAssert.CompareLineByLine(new[] |
| 62 | { |
| 63 | "MsiAssembly:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA\tProductFeature\t\t\t", |
| 64 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA\tculture\tneutral", |
| 65 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA\tfileVersion\t3.11.11810.0", |
| 66 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA\tname\tcandle", |
| 67 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA\tprocessorArchitecture\tx86", |
| 68 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA\tpublicKeyToken\t256B3414DFA97718", |
| 69 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA\tversion\t3.0.0.0" |
| 70 | }, rows); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | [Fact] |
| 75 | public void CanBuildWithAssemblyInModule() |
| 76 | { |
| 77 | var folder = TestData.Get(@"TestData", "Assembly"); |
| 78 | |
| 79 | using (var fs = new DisposableFileSystem()) |
| 80 | { |
| 81 | var baseFolder = fs.GetFolder(); |
| 82 | var msmPath = Path.Combine(baseFolder, "bin", "test.msm"); |
| 83 | |
| 84 | var result = WixRunner.Execute(new[] |
| 85 | { |
| 86 | "build", |
| 87 | Path.Combine(folder, "Module.wxs"), |
| 88 | Path.Combine(folder, "PackageComponents.wxs"), |
| 89 | "-bindpath", Path.Combine(folder, "data"), |
| 90 | "-intermediateFolder", Path.Combine(baseFolder, "obj"), |
| 91 | "-o", msmPath |
| 92 | }); |
| 93 | |
| 94 | result.AssertSuccess(); |
| 95 | |
| 96 | var rows = Query.QueryDatabase(msmPath, new[] { "MsiAssembly", "MsiAssemblyName" }); |
| 97 | WixAssert.CompareLineByLine(new[] |
| 98 | { |
| 99 | "MsiAssembly:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA.147730A5_30FE_4A62_A520_DA9381B8226A\t{00000000-0000-0000-0000-000000000000}\t\t\t", |
| 100 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA.147730A5_30FE_4A62_A520_DA9381B8226A\tculture\tneutral", |
| 101 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA.147730A5_30FE_4A62_A520_DA9381B8226A\tfileVersion\t3.11.11810.0", |
| 102 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA.147730A5_30FE_4A62_A520_DA9381B8226A\tname\tcandle", |
| 103 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA.147730A5_30FE_4A62_A520_DA9381B8226A\tprocessorArchitecture\tx86", |
| 104 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA.147730A5_30FE_4A62_A520_DA9381B8226A\tpublicKeyToken\t256B3414DFA97718", |
| 105 | "MsiAssemblyName:fil1B9Dd3yyw7a4WVD.MROlfbKT_KA.147730A5_30FE_4A62_A520_DA9381B8226A\tversion\t3.0.0.0" |
| 106 | }, rows); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | [Fact] |
| 111 | public void CanBuildWithNet1xAssembly() |
| 112 | { |
| 113 | var folder = TestData.Get("TestData", "Assembly1x"); |
| 114 | |
| 115 | using (var fs = new DisposableFileSystem()) |
| 116 | { |
| 117 | var baseFolder = fs.GetFolder(); |
| 118 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 119 | |
| 120 | var result = WixRunner.Execute(new[] |
| 121 | { |
| 122 | "build", |
| 123 | Path.Combine(folder, "Package.wxs"), |
| 124 | Path.Combine(folder, "PackageComponents.wxs"), |
| 125 | "-loc", Path.Combine(folder, "Package.en-us.wxl"), |
| 126 | "-bindpath", Path.Combine(folder, "data"), |
| 127 | "-intermediateFolder", intermediateFolder, |
| 128 | "-o", Path.Combine(baseFolder, "bin", "test.msi") |
| 129 | }); |
| 130 | |
| 131 | result.AssertSuccess(); |
| 132 | |
| 133 | Assert.True(File.Exists(Path.Combine(baseFolder, "bin", "test.msi"))); |
| 134 | Assert.True(File.Exists(Path.Combine(baseFolder, "bin", "test.wixpdb"))); |
| 135 | Assert.True(File.Exists(Path.Combine(baseFolder, "bin", "PFiles", "AssemblyMsiPackage", "candle.exe"))); |
| 136 | |
| 137 | var intermediate = Intermediate.Load(Path.Combine(baseFolder, "bin", "test.wixpdb")); |
| 138 | var section = intermediate.Sections.Single(); |
| 139 | |
| 140 | var fileSymbol = section.Symbols.OfType<FileSymbol>().Single(); |
| 141 | WixAssert.StringEqual(Path.Combine(folder, "data", "candle.exe"), fileSymbol[FileSymbolFields.Source].AsPath().Path); |
| 142 | WixAssert.StringEqual("candle.exe", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path); |
| 143 | |
| 144 | var msiAssemblyNameSymbols = section.Symbols.OfType<MsiAssemblyNameSymbol>(); |
| 145 | WixAssert.CompareLineByLine(new[] |
| 146 | { |
| 147 | "culture", |
| 148 | "fileVersion", |
| 149 | "name", |
| 150 | "publicKeyToken", |
| 151 | "version" |
| 152 | }, msiAssemblyNameSymbols.OrderBy(a => a.Name).Select(a => a.Name).ToArray()); |
| 153 | |
| 154 | WixAssert.CompareLineByLine(new[] |
| 155 | { |
| 156 | "neutral", |
| 157 | "2.0.5805.0", |
| 158 | "candle", |
| 159 | "CE35F76FCDA82BAD", |
| 160 | "2.0.5805.0", |
| 161 | }, msiAssemblyNameSymbols.OrderBy(a => a.Name).Select(a => a.Value).ToArray()); |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | } |