@joebigelow / wix-1 / commits / 7b583330

Move short filename generation to the WindowsInstallerBackend

Rob Mensching committed Jul 5, 2020 at 23:08 UTC 7b583330fd42356930bdc5a28820e546f6ca45a4
6 files changed +171 -159
src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
+137 -6
@@ -5,7 +5,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind
5 using System;
6 using System.Collections.Generic;
7 using System.Globalization;
8 + using System.IO;
9 using System.Linq;
10 + using System.Security.Cryptography;
11 + using System.Text;
12 using WixToolset.Data;
13 using WixToolset.Data.Symbols;
14 using WixToolset.Data.WindowsInstaller;
@@ -97,6 +100,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind
100 this.AddDirectorySymbol((DirectorySymbol)symbol);
101 break;
102
103 + case SymbolDefinitionType.DuplicateFile:
104 + this.AddDuplicateFileSymbol((DuplicateFileSymbol)symbol);
105 + break;
106 +
107 case SymbolDefinitionType.Environment:
108 this.AddEnvironmentSymbol((EnvironmentSymbol)symbol);
109 break;
@@ -117,6 +124,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind
124 this.AddIniFileSymbol((IniFileSymbol)symbol);
125 break;
126
127 + case SymbolDefinitionType.IniLocator:
128 + this.AddIniLocatorSymbol((IniLocatorSymbol)symbol);
129 + break;
130 +
131 case SymbolDefinitionType.Media:
132 this.AddMediaSymbol((MediaSymbol)symbol);
133 break;
@@ -444,6 +455,16 @@ namespace WixToolset.Core.WindowsInstaller.Bind
455
456 private void AddDirectorySymbol(DirectorySymbol symbol)
457 {
458 + if (String.IsNullOrEmpty(symbol.ShortName) && !symbol.Name.Equals(".") && !symbol.Name.Equals("SourceDir") && !Common.IsValidShortFilename(symbol.Name, false))
459 + {
460 + symbol.ShortName = CreateShortName(symbol.Name, false, false, "Directory", symbol.ParentDirectoryRef);
461 + }
462 +
463 + if (String.IsNullOrEmpty(symbol.SourceShortName) && !String.IsNullOrEmpty(symbol.SourceName) && !Common.IsValidShortFilename(symbol.SourceName, false))
464 + {
465 + symbol.SourceShortName = CreateShortName(symbol.SourceName, false, false, "Directory", symbol.ParentDirectoryRef);
466 + }
467 +
468 var sourceName = GetMsiFilenameValue(symbol.SourceShortName, symbol.SourceName);
469 var targetName = GetMsiFilenameValue(symbol.ShortName, symbol.Name);
470
@@ -460,6 +481,22 @@ namespace WixToolset.Core.WindowsInstaller.Bind
481 row[2] = defaultDir;
482 }
483
484 + private void AddDuplicateFileSymbol(DuplicateFileSymbol symbol)
485 + {
486 + var name = symbol.DestinationName;
487 + if (null == symbol.DestinationShortName && null != name && !Common.IsValidShortFilename(name, false))
488 + {
489 + symbol.DestinationShortName = CreateShortName(name, true, false, "CopyFile", symbol.ComponentRef, symbol.FileRef);
490 + }
491 +
492 + var row = this.CreateRow(symbol, "DuplicateFile");
493 + row[0] = symbol.Id.Id;
494 + row[1] = symbol.ComponentRef;
495 + row[2] = symbol.FileRef;
496 + row[3] = GetMsiFilenameValue(symbol.DestinationShortName, symbol.DestinationName);
497 + row[4] = symbol.DestinationFolder;
498 + }
499 +
500 private void AddEnvironmentSymbol(EnvironmentSymbol symbol)
501 {
502 var action = String.Empty;
@@ -525,10 +562,16 @@ namespace WixToolset.Core.WindowsInstaller.Bind
562
563 private void AddFileSymbol(FileSymbol symbol)
564 {
565 + var name = symbol.Name;
566 + if (null == symbol.ShortName && null != name && !Common.IsValidShortFilename(name, false))
567 + {
568 + symbol.ShortName = CreateShortName(name, true, false, "File", symbol.DirectoryRef);
569 + }
570 +
571 var row = (FileRow)this.CreateRow(symbol, "File");
572 row.File = symbol.Id.Id;
573 row.Component = symbol.ComponentRef;
531 - row.FileName = GetMsiFilenameValue(symbol.ShortName, symbol.Name);
574 + row.FileName = GetMsiFilenameValue(symbol.ShortName, name);
575 row.FileSize = symbol.FileSize;
576 row.Version = symbol.Version;
577 row.Language = symbol.Language;
@@ -564,9 +607,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind
607 {
608 var tableName = (InifFileActionType.AddLine == symbol.Action || InifFileActionType.AddTag == symbol.Action || InifFileActionType.CreateLine == symbol.Action) ? "IniFile" : "RemoveIniFile";
609
610 + var name = symbol.FileName;
611 + if (null == symbol.ShortFileName && null != name && !Common.IsValidShortFilename(name, false))
612 + {
613 + symbol.ShortFileName = CreateShortName(name, true, false, "IniFile", symbol.ComponentRef);
614 + }
615 +
616 var row = this.CreateRow(symbol, tableName);
617 row[0] = symbol.Id.Id;
569 - row[1] = symbol.FileName;
618 + row[1] = GetMsiFilenameValue(symbol.ShortFileName, name);
619 row[2] = symbol.DirProperty;
620 row[3] = symbol.Section;
621 row[4] = symbol.Key;
@@ -575,6 +624,23 @@ namespace WixToolset.Core.WindowsInstaller.Bind
624 row[7] = symbol.ComponentRef;
625 }
626
627 + private void AddIniLocatorSymbol(IniLocatorSymbol symbol)
628 + {
629 + var name = symbol.FileName;
630 + if (null == symbol.ShortFileName && null != name && !Common.IsValidShortFilename(name, false))
631 + {
632 + symbol.ShortFileName = CreateShortName(name, true, false, "IniFileSearch");
633 + }
634 +
635 + var row = this.CreateRow(symbol, "IniLocator");
636 + row[0] = symbol.Id.Id;
637 + row[1] = GetMsiFilenameValue(symbol.ShortFileName, name);
638 + row[2] = symbol.Section;
639 + row[3] = symbol.Key;
640 + row[4] = symbol.Field;
641 + row[5] = symbol.Type;
642 + }
643 +
644 private void AddMediaSymbol(MediaSymbol symbol)
645 {
646 if (this.Section.Type != SectionType.Module)
@@ -653,11 +719,17 @@ namespace WixToolset.Core.WindowsInstaller.Bind
719
720 private void AddMoveFileSymbol(MoveFileSymbol symbol)
721 {
722 + var name = symbol.DestinationName;
723 + if (null == symbol.DestinationShortName && null != name && !Common.IsValidShortFilename(name, false))
724 + {
725 + symbol.DestinationShortName = CreateShortName(name, true, false, "MoveFile", symbol.ComponentRef);
726 + }
727 +
728 var row = this.CreateRow(symbol, "MoveFile");
729 row[0] = symbol.Id.Id;
730 row[1] = symbol.ComponentRef;
731 row[2] = symbol.SourceName;
660 - row[3] = symbol.DestName;
732 + row[3] = GetMsiFilenameValue(symbol.DestinationShortName, symbol.DestinationName);
733 row[4] = symbol.SourceFolder;
734 row[5] = symbol.DestFolder;
735 row[6] = symbol.Delete ? WindowsInstallerConstants.MsidbMoveFileOptionsMove : 0;
@@ -677,14 +749,20 @@ namespace WixToolset.Core.WindowsInstaller.Bind
749
750 private void AddRemoveFileSymbol(RemoveFileSymbol symbol)
751 {
752 + var name = symbol.FileName;
753 + if (null == symbol.ShortFileName && null != name && !Common.IsValidShortFilename(name, false))
754 + {
755 + symbol.ShortFileName = CreateShortName(name, true, false, "RemoveFile", symbol.ComponentRef);
756 + }
757 +
758 var installMode = symbol.OnInstall == true ? WindowsInstallerConstants.MsidbRemoveFileInstallModeOnInstall : 0;
759 installMode |= symbol.OnUninstall == true ? WindowsInstallerConstants.MsidbRemoveFileInstallModeOnRemove : 0;
760
761 var row = this.CreateRow(symbol, "RemoveFile");
762 row[0] = symbol.Id.Id;
763 row[1] = symbol.ComponentRef;
686 - row[2] = symbol.FileName;
687 - row[3] = symbol.DirProperty;
764 + row[2] = GetMsiFilenameValue(symbol.ShortFileName, symbol.FileName);
765 + row[3] = symbol.DirPropertyRef;
766 row[4] = installMode;
767 }
768
@@ -821,10 +899,16 @@ namespace WixToolset.Core.WindowsInstaller.Bind
899
900 private void AddShortcutSymbol(ShortcutSymbol symbol)
901 {
902 + var name = symbol.Name;
903 + if (null == symbol.ShortName && null != name && !Common.IsValidShortFilename(name, false))
904 + {
905 + symbol.ShortName = CreateShortName(name, true, false, "Shortcut", symbol.ComponentRef, symbol.DirectoryRef);
906 + }
907 +
908 var row = this.CreateRow(symbol, "Shortcut");
909 row[0] = symbol.Id.Id;
910 row[1] = symbol.DirectoryRef;
827 - row[2] = GetMsiFilenameValue(symbol.ShortName, symbol.Name);
911 + row[2] = GetMsiFilenameValue(symbol.ShortName, name);
912 row[3] = symbol.ComponentRef;
913 row[4] = symbol.Target;
914 row[5] = symbol.Arguments;
@@ -1117,5 +1201,52 @@ namespace WixToolset.Core.WindowsInstaller.Bind
1201 return shortName + "|" + longName;
1202 }
1203 }
1204 +
1205 + private static string CreateShortName(string longName, bool keepExtension, bool allowWildcards, params string[] args)
1206 + {
1207 + longName = longName.ToLowerInvariant();
1208 +
1209 + // collect all the data
1210 + var strings = new List<string>(1 + args.Length);
1211 + strings.Add(longName);
1212 + strings.AddRange(args);
1213 +
1214 + // prepare for hashing
1215 + var stringData = String.Join("|", strings);
1216 + var data = Encoding.UTF8.GetBytes(stringData);
1217 +
1218 + // hash the data
1219 + byte[] hash;
1220 + using (var sha1 = new SHA1CryptoServiceProvider())
1221 + {
1222 + hash = sha1.ComputeHash(data);
1223 + }
1224 +
1225 + // generate the short file/directory name without an extension
1226 + var shortName = new StringBuilder(Convert.ToBase64String(hash));
1227 + shortName.Length = 8;
1228 + shortName.Replace('+', '-').Replace('/', '_');
1229 +
1230 + if (keepExtension)
1231 + {
1232 + var extension = Path.GetExtension(longName);
1233 +
1234 + if (4 < extension.Length)
1235 + {
1236 + extension = extension.Substring(0, 4);
1237 + }
1238 +
1239 + shortName.Append(extension);
1240 +
1241 + // check the generated short name to ensure its still legal (the extension may not be legal)
1242 + if (!Common.IsValidShortFilename(shortName.ToString(), allowWildcards))
1243 + {
1244 + // remove the extension (by truncating the generated file name back to the generated characters)
1245 + shortName.Length -= extension.Length;
1246 + }
1247 + }
1248 +
1249 + return shortName.ToString().ToLowerInvariant();
1250 + }
1251 }
1252 }
src/WixToolset.Core/Common.cs
+1 -1
@@ -188,7 +188,7 @@ namespace WixToolset.Core
188 /// <param name="filename">Filename to verify.</param>
189 /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
190 /// <returns>True if the filename is a valid short filename</returns>
191 - internal static bool IsValidShortFilename(string filename, bool allowWildcards)
191 + public static bool IsValidShortFilename(string filename, bool allowWildcards)
192 {
193 if (String.IsNullOrEmpty(filename))
194 {
src/WixToolset.Core/Compiler.cs
+25 -99
@@ -299,24 +299,6 @@ namespace WixToolset.Core
299 return s?.ToLowerInvariant();
300 }
301
302 - /// <summary>
303 - /// Given a possible short and long file name, create an msi filename value.
304 - /// </summary>
305 - /// <param name="shortName">The short file name.</param>
306 - /// <param name="longName">Possibly the long file name.</param>
307 - /// <returns>The value in the msi filename data type.</returns>
308 - private string GetMsiFilenameValue(string shortName, string longName)
309 - {
310 - if (null != shortName && null != longName && !String.Equals(shortName, longName, StringComparison.OrdinalIgnoreCase))
311 - {
312 - return String.Concat(shortName, "|", longName);
313 - }
314 - else
315 - {
316 - return this.Core.IsValidShortFilename(longName, false) ? longName : shortName;
317 - }
318 - }
319 -
302 /// <summary>
303 /// Adds a search property to the active section.
304 /// </summary>
@@ -3036,12 +3018,6 @@ namespace WixToolset.Core
3018 this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "DestinationProperty", "DestinationDirectory"));
3019 }
3020
3039 - // generate a short file name
3040 - if (null == destinationShortName && (null != destinationName && !this.Core.IsValidShortFilename(destinationName, false)))
3041 - {
3042 - destinationShortName = this.Core.CreateShortName(destinationName, true, false, node.Name.LocalName, componentId);
3043 - }
3044 -
3021 if (null == id)
3022 {
3023 id = this.Core.CreateIdentifier("cf", sourceFolder, sourceDirectory, sourceProperty, destinationDirectory, destinationProperty, destinationName);
@@ -3063,7 +3039,8 @@ namespace WixToolset.Core
3039 {
3040 ComponentRef = componentId,
3041 SourceName = sourceName,
3066 - DestName= String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : this.GetMsiFilenameValue(destinationShortName, destinationName),
3042 + DestinationName = destinationName,
3043 + DestinationShortName = destinationShortName,
3044 SourceFolder = sourceDirectory ?? sourceProperty,
3045 DestFolder = destinationDirectory ?? destinationProperty,
3046 Delete = delete,
@@ -3108,7 +3085,8 @@ namespace WixToolset.Core
3085 {
3086 ComponentRef = componentId,
3087 FileRef = fileId,
3111 - DestinationName = String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : this.GetMsiFilenameValue(destinationShortName, destinationName),
3088 + DestinationName = destinationName,
3089 + DestinationShortName = destinationShortName,
3090 DestinationFolder = destinationDirectory ?? destinationProperty,
3091 });
3092 }
@@ -4184,16 +4162,12 @@ namespace WixToolset.Core
4162 {
4163 if (String.IsNullOrEmpty(shortName))
4164 {
4187 - if (!name.Equals(".") && !name.Equals("SourceDir") && !this.Core.IsValidShortFilename(name, false))
4188 - {
4189 - shortName = this.Core.CreateShortName(name, false, false, "Directory", parentId);
4190 - }
4165 }
4192 - else if (name.Equals("."))
4166 + else if (name == ".")
4167 {
4168 this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "ShortName", "Name", name));
4169 }
4196 - else if (name.Equals(shortName))
4170 + else if (name.Equals(shortName, StringComparison.OrdinalIgnoreCase))
4171 {
4172 this.Core.Write(WarningMessages.DirectoryRedundantNames(sourceLineNumbers, node.Name.LocalName, "Name", "ShortName", name));
4173 }
@@ -4210,16 +4184,12 @@ namespace WixToolset.Core
4184 {
4185 if (String.IsNullOrEmpty(shortSourceName))
4186 {
4213 - if (!sourceName.Equals(".") && !this.Core.IsValidShortFilename(sourceName, false))
4214 - {
4215 - shortSourceName = this.Core.CreateShortName(sourceName, false, false, "Directory", parentId);
4216 - }
4187 }
4218 - else if (sourceName.Equals("."))
4188 + else if (sourceName == ".")
4189 {
4190 this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "ShortSourceName", "SourceName", sourceName));
4191 }
4222 - else if (sourceName.Equals(shortSourceName))
4192 + else if (sourceName.Equals(shortSourceName, StringComparison.OrdinalIgnoreCase))
4193 {
4194 this.Core.Write(WarningMessages.DirectoryRedundantNames(sourceLineNumbers, node.Name.LocalName, "SourceName", "ShortSourceName", sourceName));
4195 }
@@ -5463,7 +5433,6 @@ namespace WixToolset.Core
5433 var defaultSize = 0;
5434 string defaultVersion = null;
5435 string fontTitle = null;
5466 - var generatedShortFileName = false;
5436 var keyPath = YesNoType.NotSet;
5437 string name = null;
5438 var patchGroup = CompilerConstants.IntegerNotSet;
@@ -5686,16 +5655,22 @@ namespace WixToolset.Core
5655 }
5656 }
5657
5689 - // generate a short file name
5690 - if (null == shortName && (null != name && !this.Core.IsValidShortFilename(name, false)))
5658 + if (name == null)
5659 {
5692 - shortName = this.Core.CreateShortName(name, true, false, node.Name.LocalName, directoryId);
5693 - generatedShortFileName = true;
5660 + if (shortName == null)
5661 + {
5662 + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name"));
5663 + }
5664 + else
5665 + {
5666 + name = shortName;
5667 + shortName = null;
5668 + }
5669 }
5670
5671 if (null == id)
5672 {
5698 - id = this.Core.CreateIdentifier("fil", directoryId, name ?? shortName);
5673 + id = this.Core.CreateIdentifier("fil", directoryId, name);
5674 }
5675
5676 if (null != defaultVersion && null != companionFile)
@@ -5811,11 +5786,11 @@ namespace WixToolset.Core
5786
5787 if (String.IsNullOrEmpty(source))
5788 {
5814 - source = name ?? shortName;
5789 + source = name;
5790 }
5791 else if (source.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) // if source relies on parent directories, append the file name
5792 {
5818 - source = null == name ? Path.Combine(source, shortName) : Path.Combine(source, name);
5793 + source = Path.Combine(source, name);
5794 }
5795
5796 var attributes = FileSymbolAttributes.None;
@@ -5826,7 +5801,6 @@ namespace WixToolset.Core
5801 attributes |= checksum ? FileSymbolAttributes.Checksum : 0;
5802 attributes |= compressed.HasValue && compressed == true ? FileSymbolAttributes.Compressed : 0;
5803 attributes |= compressed.HasValue && compressed == false ? FileSymbolAttributes.Uncompressed : 0;
5829 - attributes |= generatedShortFileName ? FileSymbolAttributes.GeneratedShortFileName : 0;
5804
5805 this.Core.AddSymbol(new FileSymbol(sourceLineNumbers, id)
5806 {
@@ -5838,14 +5812,6 @@ namespace WixToolset.Core
5812 Language = defaultLanguage,
5813 Attributes = attributes,
5814
5841 - //ReadOnly = readOnly,
5842 - //Hidden = hidden,
5843 - //System = system,
5844 - //Vital = vital,
5845 - //Checksum = checksum,
5846 - //Compressed = compressed,
5847 - //GeneratedShortFileName = generatedShortFileName,
5848 -
5815 DirectoryRef = directoryId,
5816 DiskId = (CompilerConstants.IntegerNotSet == diskId) ? null : (int?)diskId,
5817 Source = new IntermediateFieldPathValue { Path = source },
@@ -6454,28 +6420,6 @@ namespace WixToolset.Core
6420 {
6421 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name"));
6422 }
6457 - else if (0 < name.Length)
6458 - {
6459 - if (this.Core.IsValidShortFilename(name, false))
6460 - {
6461 - if (null == shortName)
6462 - {
6463 - shortName = name;
6464 - name = null;
6465 - }
6466 - else
6467 - {
6468 - this.Core.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Name", name, "ShortName"));
6469 - }
6470 - }
6471 - else // generate a short file name.
6472 - {
6473 - if (null == shortName)
6474 - {
6475 - shortName = this.Core.CreateShortName(name, true, false, node.Name.LocalName, componentId);
6476 - }
6477 - }
6478 - }
6423
6424 if (null == section)
6425 {
@@ -6493,7 +6437,8 @@ namespace WixToolset.Core
6437 {
6438 this.Core.AddSymbol(new IniFileSymbol(sourceLineNumbers, id)
6439 {
6496 - FileName = this.GetMsiFilenameValue(shortName, name),
6440 + FileName = name,
6441 + ShortFileName = shortName,
6442 DirProperty = directory,
6443 Section = section,
6444 Key = key,
@@ -6585,25 +6530,6 @@ namespace WixToolset.Core
6530 {
6531 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name"));
6532 }
6588 - else if (0 < name.Length)
6589 - {
6590 - if (this.Core.IsValidShortFilename(name, false))
6591 - {
6592 - if (null == shortName)
6593 - {
6594 - shortName = name;
6595 - name = null;
6596 - }
6597 - else
6598 - {
6599 - this.Core.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Name", name, "ShortName"));
6600 - }
6601 - }
6602 - else if (null == shortName) // generate a short file name.
6603 - {
6604 - shortName = this.Core.CreateShortName(name, true, false, node.Name.LocalName);
6605 - }
6606 - }
6533
6534 if (null == section)
6535 {
@@ -6677,8 +6603,8 @@ namespace WixToolset.Core
6603 {
6604 var symbol = this.Core.AddSymbol(new IniLocatorSymbol(sourceLineNumbers, id)
6605 {
6680 - SignatureRef = id.Id,
6681 - FileName = this.GetMsiFilenameValue(shortName, name),
6606 + FileName = name,
6607 + ShortFileName = shortName,
6608 Section = section,
6609 Key = key,
6610 Type = type
src/WixToolset.Core/CompilerCore.cs
+1
@@ -286,6 +286,7 @@ namespace WixToolset.Core
286 /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
287 /// <param name="args">Any additional information to include in the hash for the generated short name.</param>
288 /// <returns>The generated 8.3-compliant short file/directory name.</returns>
289 + [Obsolete]
290 public string CreateShortName(string longName, bool keepExtension, bool allowWildcards, params string[] args)
291 {
292 return this.parseHelper.CreateShortName(longName, keepExtension, allowWildcards, args);
src/WixToolset.Core/Compiler_2.cs
+5 -41
@@ -2309,25 +2309,6 @@ namespace WixToolset.Core
2309 {
2310 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name"));
2311 }
2312 - else if (0 < name.Length)
2313 - {
2314 - if (this.Core.IsValidShortFilename(name, true))
2315 - {
2316 - if (null == shortName)
2317 - {
2318 - shortName = name;
2319 - name = null;
2320 - }
2321 - else
2322 - {
2323 - this.Core.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Name", name, "ShortName"));
2324 - }
2325 - }
2326 - else if (null == shortName) // generate a short file name.
2327 - {
2328 - shortName = this.Core.CreateShortName(name, true, true, node.Name.LocalName, componentId);
2329 - }
2330 - }
2312
2313 if (!onInstall.HasValue && !onUninstall.HasValue)
2314 {
@@ -2352,8 +2333,9 @@ namespace WixToolset.Core
2333 this.Core.AddSymbol(new RemoveFileSymbol(sourceLineNumbers, id)
2334 {
2335 ComponentRef = componentId,
2355 - FileName = this.GetMsiFilenameValue(shortName, name),
2356 - DirProperty = directory ?? property ?? parentDirectory,
2336 + FileName = name,
2337 + ShortFileName = shortName,
2338 + DirPropertyRef = directory ?? property ?? parentDirectory,
2339 OnInstall = onInstall,
2340 OnUninstall = onUninstall,
2341 });
@@ -2440,7 +2422,7 @@ namespace WixToolset.Core
2422 this.Core.AddSymbol(new RemoveFileSymbol(sourceLineNumbers, id)
2423 {
2424 ComponentRef = componentId,
2443 - DirProperty = directory ?? property ?? parentDirectory,
2425 + DirPropertyRef = directory ?? property ?? parentDirectory,
2426 OnInstall = onInstall,
2427 OnUninstall = onUninstall
2428 });
@@ -4293,24 +4275,6 @@ namespace WixToolset.Core
4275 {
4276 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name"));
4277 }
4296 - else if (0 < name.Length)
4297 - {
4298 - if (this.Core.IsValidShortFilename(name, false))
4299 - {
4300 - if (null == shortName)
4301 - {
4302 - shortName = name;
4303 - }
4304 - else
4305 - {
4306 - this.Core.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Name", name, "ShortName"));
4307 - }
4308 - }
4309 - else if (null == shortName) // generate a short file name.
4310 - {
4311 - shortName = this.Core.CreateShortName(name, true, false, node.Name.LocalName, componentId, directory);
4312 - }
4313 - }
4278
4279 if ("Component" != parentElementLocalName && null != target)
4280 {
@@ -4319,7 +4283,7 @@ namespace WixToolset.Core
4283
4284 if (null == id)
4285 {
4322 - id = this.Core.CreateIdentifier("sct", directory, LowercaseOrNull(name) ?? LowercaseOrNull(shortName));
4286 + id = this.Core.CreateIdentifier("sct", directory, LowercaseOrNull(name));
4287 }
4288
4289 foreach (var child in node.Elements())
src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
+2 -12
@@ -75,16 +75,6 @@ namespace WixToolset.Core.ExtensibilityServices
75
76 public Identifier CreateDirectorySymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, ISet<string> sectionInlinedDirectoryIds, string shortName = null, string sourceName = null, string shortSourceName = null)
77 {
78 - if (String.IsNullOrEmpty(shortName) && !name.Equals("SourceDir") && !this.IsValidShortFilename(name))
79 - {
80 - shortName = this.CreateShortName(name, false, false, "Directory", parentId);
81 - }
82 -
83 - if (String.IsNullOrEmpty(shortSourceName) && !String.IsNullOrEmpty(sourceName) && !this.IsValidShortFilename(sourceName))
84 - {
85 - shortSourceName = this.CreateShortName(sourceName, false, false, "Directory", parentId);
86 - }
87 -
78 // For anonymous directories, create the identifier. If this identifier already exists in the
79 // active section, bail so we don't add duplicate anonymous directory symbols (which are legal
80 // but bloat the intermediate and ultimately make the linker do "busy work").
@@ -243,7 +233,7 @@ namespace WixToolset.Core.ExtensibilityServices
233
234 if (null == childId)
235 {
246 - throw new ArgumentNullException("childId");
236 + throw new ArgumentNullException(nameof(childId));
237 }
238
239 section.AddSymbol(new WixGroupSymbol(sourceLineNumbers)
@@ -419,7 +409,7 @@ namespace WixToolset.Core.ExtensibilityServices
409 {
410 if (null == attribute)
411 {
422 - throw new ArgumentNullException("attribute");
412 + throw new ArgumentNullException(nameof(attribute));
413 }
414
415 var emptyRule = canBeEmpty ? EmptyRule.CanBeEmpty : EmptyRule.CanBeWhitespaceOnly;