Integrate short and source name changes to Directory and Shortcut tuples
Rob Mensching committed
May 22, 2019 at 16:28 UTC
3051bf2fc300df125115c9538a0bfc8256bfde6a
7 files changed
+55
-93
src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs
+3
-4
@@ -76,18 +76,17 @@ namespace WixToolset.Core.WindowsInstaller.Bind
76
targetPathsByDirectoryId = new Dictionary<string, ResolvedDirectory>(directories.Count);
77
78
// Get the target paths for all directories.
79
- foreach (var row in directories)
79
+ foreach (var directory in directories)
80
{
81
// If the directory Id already exists, we will skip it here since
82
// checking for duplicate primary keys is done later when importing tables
83
// into database
84
- if (targetPathsByDirectoryId.ContainsKey(row.Id.Id))
84
+ if (targetPathsByDirectoryId.ContainsKey(directory.Id.Id))
85
{
86
continue;
87
}
88
89
- var targetName = Common.GetName(row.DefaultDir, false, true);
90
- targetPathsByDirectoryId.Add(row.Id.Id, new ResolvedDirectory(row.ParentDirectoryRef, targetName));
89
+ targetPathsByDirectoryId.Add(directory.Id.Id, new ResolvedDirectory(directory.ParentDirectoryRef, directory.Name));
90
}
91
}
92
src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
+35
-3
@@ -146,7 +146,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
146
break;
147
148
case TupleDefinitionType.Shortcut:
149
- this.AddTupleDefaultly(tuple, output, true);
149
+ this.AddShortcutTuple((ShortcutTuple)tuple, output);
150
break;
151
152
case TupleDefinitionType.TextStyle:
@@ -338,11 +338,21 @@ namespace WixToolset.Core.WindowsInstaller.Bind
338
339
private void AddDirectoryTuple(DirectoryTuple tuple, Output output)
340
{
341
+ var shortName = GetMsiFilenameValue(tuple.SourceShortName, tuple.SourceName);
342
+ var targetName = GetMsiFilenameValue(tuple.ShortName, tuple.Name);
343
+
344
+ if (String.IsNullOrEmpty(targetName))
345
+ {
346
+ targetName = ".";
347
+ }
348
+
349
+ var defaultDir = String.IsNullOrEmpty(shortName)? targetName : shortName + ":" + targetName;
350
+
351
var table = output.EnsureTable(this.TableDefinitions["Directory"]);
352
var row = table.CreateRow(tuple.SourceLineNumbers);
353
row[0] = tuple.Id.Id;
354
row[1] = tuple.ParentDirectoryRef;
345
- row[2] = tuple.DefaultDir;
355
+ row[2] = defaultDir;
356
}
357
358
private void AddEnvironmentTuple(EnvironmentTuple tuple, Output output)
@@ -447,7 +457,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
457
var table = output.EnsureTable(this.TableDefinitions["Media"]);
458
var row = (MediaRow)table.CreateRow(tuple.SourceLineNumbers);
459
row.DiskId = tuple.DiskId;
450
- row.LastSequence = tuple.LastSequence;
460
+ row.LastSequence = tuple.LastSequence ?? 0;
461
row.DiskPrompt = tuple.DiskPrompt;
462
row.Cabinet = tuple.Cabinet;
463
row.VolumeLabel = tuple.VolumeLabel;
@@ -695,6 +705,28 @@ namespace WixToolset.Core.WindowsInstaller.Bind
705
row[12] = tuple.Description;
706
}
707
708
+ private void AddShortcutTuple(ShortcutTuple tuple, Output output)
709
+ {
710
+ var table = output.EnsureTable(this.TableDefinitions["Shortcut"]);
711
+ var row = table.CreateRow(tuple.SourceLineNumbers);
712
+ row[0] = tuple.Id.Id;
713
+ row[1] = tuple.DirectoryRef;
714
+ row[2] = GetMsiFilenameValue(tuple.ShortName, tuple.Name);
715
+ row[3] = tuple.ComponentRef;
716
+ row[4] = tuple.Target;
717
+ row[5] = tuple.Arguments;
718
+ row[6] = tuple.Description;
719
+ row[7] = tuple.Hotkey;
720
+ row[8] = tuple.IconRef;
721
+ row[9] = tuple.IconIndex;
722
+ row[10] = (int)tuple.Show;
723
+ row[11] = tuple.WorkingDirectory;
724
+ row[12] = tuple.DisplayResourceDll;
725
+ row[13] = tuple.DisplayResourceId;
726
+ row[14] = tuple.DescriptionResourceDll;
727
+ row[15] = tuple.DescriptionResourceId;
728
+ }
729
+
730
private void AddTextStyleTuple(TextStyleTuple tuple, Output output)
731
{
732
var styleBits = tuple.Bold ? WindowsInstallerConstants.MsidbTextStyleStyleBitsBold : 0;
src/WixToolset.Core/Compiler.cs
+5
-3
@@ -4028,7 +4028,6 @@ namespace WixToolset.Core
4028
string shortName = null;
4029
string sourceName = null;
4030
string shortSourceName = null;
4031
- string defaultDir = null;
4031
string symbols = null;
4032
4033
foreach (var attrib in node.Attributes())
@@ -4208,7 +4207,7 @@ namespace WixToolset.Core
4207
}
4208
4209
// Calculate the DefaultDir for the directory row.
4211
- defaultDir = String.IsNullOrEmpty(shortName) ? name : String.Concat(shortName, "|", name);
4210
+ var defaultDir = String.IsNullOrEmpty(shortName) ? name : String.Concat(shortName, "|", name);
4211
if (!String.IsNullOrEmpty(sourceName))
4212
{
4213
defaultDir = String.Concat(defaultDir, ":", String.IsNullOrEmpty(shortSourceName) ? sourceName : String.Concat(shortSourceName, "|", sourceName));
@@ -4260,7 +4259,10 @@ namespace WixToolset.Core
4259
var tuple = new DirectoryTuple(sourceLineNumbers, id)
4260
{
4261
ParentDirectoryRef = parentId,
4263
- DefaultDir = defaultDir,
4262
+ Name = name,
4263
+ ShortName = shortName,
4264
+ SourceName = sourceName,
4265
+ SourceShortName = shortSourceName,
4266
ComponentGuidGenerationSeed = componentGuidGenerationSeed
4267
};
4268
src/WixToolset.Core/Compiler_2.cs
+2
-53
@@ -4401,7 +4401,8 @@ namespace WixToolset.Core
4401
var tuple = new ShortcutTuple(sourceLineNumbers, id)
4402
{
4403
DirectoryRef = directory,
4404
- Name = this.GetMsiFilenameValue(shortName, name),
4404
+ Name = name,
4405
+ ShortName = shortName,
4406
ComponentRef = componentId,
4407
Target = target,
4408
Arguments = arguments,
@@ -4418,58 +4419,6 @@ namespace WixToolset.Core
4419
};
4420
4421
this.Core.AddTuple(tuple);
4421
-
4422
- //var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.Shortcut, id);
4423
- //row.Set(1, directory);
4424
- //row.Set(2, this.GetMsiFilenameValue(shortName, name));
4425
- //row.Set(3, componentId);
4426
- //if (advertise)
4427
- //{
4428
- // if (YesNoType.Yes != parentKeyPath && "Component" != parentElementLocalName)
4429
- // {
4430
- // this.Core.Write(WarningMessages.UnclearShortcut(sourceLineNumbers, id.Id, componentId, defaultTarget));
4431
- // }
4432
- // row.Set(4, Guid.Empty.ToString("B"));
4433
- //}
4434
- //else if (null != target)
4435
- //{
4436
- // row.Set(4, target);
4437
- //}
4438
- //else if ("Component" == parentElementLocalName || "CreateFolder" == parentElementLocalName)
4439
- //{
4440
- // row.Set(4, String.Format(CultureInfo.InvariantCulture, "[{0}]", defaultTarget));
4441
- //}
4442
- //else if ("File" == parentElementLocalName)
4443
- //{
4444
- // row.Set(4, String.Format(CultureInfo.InvariantCulture, "[#{0}]", defaultTarget));
4445
- //}
4446
- //row.Set(5, arguments);
4447
- //row.Set(6, description);
4448
- //if (CompilerConstants.IntegerNotSet != hotkey)
4449
- //{
4450
- // row.Set(7, hotkey);
4451
- //}
4452
- //row.Set(8, icon);
4453
- //if (CompilerConstants.IntegerNotSet != iconIndex)
4454
- //{
4455
- // row.Set(9, iconIndex);
4456
- //}
4457
-
4458
- //if (show.HasValue)
4459
- //{
4460
- // row.Set(10, show.Value);
4461
- //}
4462
- //row.Set(11, workingDirectory);
4463
- //row.Set(12, displayResourceDll);
4464
- //if (CompilerConstants.IntegerNotSet != displayResourceId)
4465
- //{
4466
- // row.Set(13, displayResourceId);
4467
- //}
4468
- //row.Set(14, descriptionResourceDll);
4469
- //if (CompilerConstants.IntegerNotSet != descriptionResourceId)
4470
- //{
4471
- // row.Set(15, descriptionResourceId);
4472
- //}
4422
}
4423
}
4424
src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
+8
-28
@@ -77,37 +77,14 @@ namespace WixToolset.Core.ExtensibilityServices
77
78
public Identifier CreateDirectoryTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, ISet<string> sectionInlinedDirectoryIds, string shortName = null, string sourceName = null, string shortSourceName = null)
79
{
80
- string defaultDir;
81
-
82
- if (name.Equals("SourceDir") || this.IsValidShortFilename(name, false))
83
- {
84
- defaultDir = name;
85
- }
86
- else
80
+ if (String.IsNullOrEmpty(shortName) && !name.Equals("SourceDir") && !this.IsValidShortFilename(name))
81
{
88
- if (String.IsNullOrEmpty(shortName))
89
- {
90
- shortName = this.CreateShortName(name, false, false, "Directory", parentId);
91
- }
92
-
93
- defaultDir = String.Concat(shortName, "|", name);
82
+ shortName = this.CreateShortName(name, false, false, "Directory", parentId);
83
}
84
96
- if (!String.IsNullOrEmpty(sourceName))
85
+ if (String.IsNullOrEmpty(shortSourceName) && !String.IsNullOrEmpty(sourceName) && !this.IsValidShortFilename(sourceName))
86
{
98
- if (this.IsValidShortFilename(sourceName, false))
99
- {
100
- defaultDir = String.Concat(defaultDir, ":", sourceName);
101
- }
102
- else
103
- {
104
- if (String.IsNullOrEmpty(shortSourceName))
105
- {
106
- shortSourceName = this.CreateShortName(sourceName, false, false, "Directory", parentId);
107
- }
108
-
109
- defaultDir = String.Concat(defaultDir, ":", shortSourceName, "|", sourceName);
110
- }
87
+ shortSourceName = this.CreateShortName(sourceName, false, false, "Directory", parentId);
88
}
89
90
// For anonymous directories, create the identifier. If this identifier already exists in the
@@ -126,7 +103,10 @@ namespace WixToolset.Core.ExtensibilityServices
103
var tuple = new DirectoryTuple(sourceLineNumbers, id)
104
{
105
ParentDirectoryRef = parentId,
129
- DefaultDir = defaultDir,
106
+ Name = name,
107
+ ShortName = shortName,
108
+ SourceName = sourceName,
109
+ SourceShortName = shortSourceName
110
};
111
112
section.Tuples.Add(tuple);
src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
+1
-1
@@ -137,7 +137,7 @@ namespace WixToolsetTest.CoreIntegration
137
result.AssertSuccess();
138
139
Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msi")));
140
- Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\lowcab1.cab")));
140
+ Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\low1.cab")));
141
Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb")));
142
}
143
}
src/test/WixToolsetTest.CoreIntegration/TestData/SingleFileCompressed/Package.wxs
+1
-1
@@ -10,7 +10,7 @@
10
<?elseif $(MediaTemplateCompressionLevel) = ""?>
11
<MediaTemplate />
12
<?else?>
13
- <MediaTemplate CabinetTemplate="lowcab{0}.cab" CompressionLevel="$(MediaTemplateCompressionLevel)" />
13
+ <MediaTemplate CabinetTemplate="low{0}.cab" CompressionLevel="$(MediaTemplateCompressionLevel)" />
14
<?endif?>
15
16
<Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">