From 999621b156ae6be4c06205e3e992b2a76dce7926 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 8 Apr 2021 10:32:40 -0700 Subject: [PATCH] Re-enable MSI usage of only a "." in Directory/@Name --- src/WixToolset.Core/Compiler.cs | 9 +++- .../DirectoryFixture.cs | 47 +++++++++++++++++++ .../TestData/Directory/DefaultName.wxs | 13 +++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/Directory/DefaultName.wxs diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index ca9385f..c5f3a76 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs @@ -4216,7 +4216,14 @@ namespace WixToolset.Core fileSourceAttribSet = true; break; case "Name": - name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, allowRelative: true); + if ("." == attrib.Value) + { + name = attrib.Value; + } + else + { + name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, allowRelative: true); + } nameAttribute = attrib; break; case "ShortName": diff --git a/src/test/WixToolsetTest.CoreIntegration/DirectoryFixture.cs b/src/test/WixToolsetTest.CoreIntegration/DirectoryFixture.cs index e0b8550..a61bdff 100644 --- a/src/test/WixToolsetTest.CoreIntegration/DirectoryFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/DirectoryFixture.cs @@ -88,6 +88,53 @@ namespace WixToolsetTest.CoreIntegration } } + [Fact] + public void CanGetDefaultName() + { + var folder = TestData.Get(@"TestData"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "Directory", "DefaultName.wxs"), + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), + "-bindpath", Path.Combine(folder, "SingleFile", "data"), + "-intermediateFolder", intermediateFolder, + "-o", msiPath + }); + + result.AssertSuccess(); + + var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"bin\test.wixpdb")); + var section = intermediate.Sections.Single(); + + var dirSymbols = section.Symbols.OfType().ToList(); + WixAssert.CompareLineByLine(new[] + { + "BinFolder\tCompanyFolder\t.", + "CompanyFolder\tProgramFilesFolder\tExample Corporation", + "ProgramFilesFolder\tTARGETDIR\tPFiles", + "TARGETDIR\t\tSourceDir" + }, dirSymbols.OrderBy(d => d.Id.Id).Select(d => String.Join('\t', d.Id.Id, d.ParentDirectoryRef, d.Name)).ToArray()); + + var data = WindowsInstallerData.Load(Path.Combine(baseFolder, @"bin\test.wixpdb")); + var directoryRows = data.Tables["Directory"].Rows; + WixAssert.CompareLineByLine(new[] + { + "BinFolder\tCompanyFolder\t.", + "CompanyFolder\tProgramFilesFolder\tu7-b4gch|Example Corporation", + "ProgramFilesFolder\tTARGETDIR\tPFiles", + "TARGETDIR\t\tSourceDir" + }, directoryRows.Select(r => String.Join('\t', r.FieldAsString(0), r.FieldAsString(1), r.FieldAsString(2))).ToArray()); + } + } + [Fact] public void CanGetDuplicateDir() { diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Directory/DefaultName.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Directory/DefaultName.wxs new file mode 100644 index 0000000..3e7887c --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Directory/DefaultName.wxs @@ -0,0 +1,13 @@ + + + + + + + + + + + + +