@joebigelow / wix-1 / commits / 38fe36a2

Always add space to to test folder to flush out such bugs

Rob Mensching committed Mar 23, 2023 at 14:36 UTC 38fe36a2072b1abde87b52643e43a3d7ddf2a2f5
5 files changed +30 -30
src/internal/WixInternal.TestSupport/DisposableFileSystem.cs
+2 -1
@@ -35,7 +35,8 @@ namespace WixInternal.TestSupport
35
36 public string GetFolder(bool create = false)
37 {
38 - var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
38 + // Always return a path with a space in it.
39 + var path = Path.Combine(Path.GetTempPath(), ".WIXTEST " + Path.GetRandomFileName());
40
41 if (create)
42 {
src/internal/WixInternal.TestSupport/ExternalExecutable.cs
+1 -1
@@ -195,7 +195,7 @@ namespace WixInternal.TestSupport
195 sb.Append(' ');
196 }
197
198 - if (arg.IndexOf(' ') > -1)
198 + if (arg.IndexOf(' ') > -1 && !arg.EndsWith("\""))
199 {
200 sb.Append("\"");
201 sb.Append(arg);
src/internal/WixInternal.TestSupport/MsbuildUtilities.cs
+25 -26
@@ -27,7 +27,7 @@ namespace WixToolsetTest.Sdk
27 // Node reuse means that child msbuild processes can stay around after the build completes.
28 // Under that scenario, the root msbuild does not reliably close its streams which causes us to hang.
29 "-nr:false",
30 - $"-bl:{Path.ChangeExtension(projectPath, ".binlog")}"
30 + MsbuildUtilities.GetQuotedSwitch(buildSystem, "bl", Path.ChangeExtension(projectPath, ".binlog"))
31 };
32
33 if (arguments != null)
@@ -59,36 +59,35 @@ namespace WixToolsetTest.Sdk
59 }
60 }
61
62 - public static string GetQuotedPropertySwitch(BuildSystem buildSystem, string propertyName, string valueToQuote)
62 + public static string GetQuotedSwitch(BuildSystem _, string switchName, string switchValue)
63 {
64 - switch (buildSystem)
64 + // If the value ends with a backslash, escape it.
65 + if (switchValue?.EndsWith("\\") == true)
66 {
66 - case BuildSystem.DotNetCoreSdk:
67 - {
68 - // If the value ends with a backslash, double-escape it (it should end up with four backslashes).
69 - if (valueToQuote?.EndsWith("\\") == true)
70 - {
71 - valueToQuote += @"\\\";
72 - }
67 + switchValue += @"\";
68 + }
69
74 - return $"-p:{propertyName}=\\\"{valueToQuote}\\\"";
75 - }
76 - case BuildSystem.MSBuild:
77 - case BuildSystem.MSBuild64:
78 - {
79 - // If the value ends with a backslash, escape it.
80 - if (valueToQuote?.EndsWith("\\") == true)
81 - {
82 - valueToQuote += @"\";
83 - }
70 + return $"-{switchName}:\"{switchValue}\"";
71 + }
72
85 - return $"-p:{propertyName}=\"{valueToQuote}\"";
86 - }
87 - default:
88 - {
89 - throw new NotImplementedException();
90 - }
73 + public static string GetQuotedPropertySwitch(BuildSystem buildSystem, string propertyName, string propertyValue)
74 + {
75 + // If the value ends with a backslash, escape it.
76 + if (propertyValue?.EndsWith("\\") == true)
77 + {
78 + propertyValue += @"\";
79 }
80 +
81 + var quotedValue = "\"" + propertyValue + "\"";
82 +
83 + // If the value contains a semicolon then escape-quote it (wrap with the characters: \") to wrap the value
84 + // instead of just quoting the value, otherwise dotnet.exe will not pass the value to MSBuild correctly.
85 + if (buildSystem == BuildSystem.DotNetCoreSdk && propertyValue?.IndexOf(';') > -1)
86 + {
87 + quotedValue = "\\\"" + propertyValue + "\\\"";
88 + }
89 +
90 + return $"-p:{propertyName}={quotedValue}";
91 }
92
93 public static IEnumerable<string> GetToolCommandLines(MsbuildRunnerResult result, string toolName, string operation, BuildSystem buildSystem)
src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs
+1 -1
@@ -572,7 +572,7 @@ namespace WixToolsetTest.CoreIntegration
572
573 private static void CreateAdminImage(string msiPath, string targetDir)
574 {
575 - var args = $"/a {Path.ChangeExtension(msiPath, "msi")} TARGETDIR={targetDir} /qn";
575 + var args = $"/a \"{Path.ChangeExtension(msiPath, "msi")}\" TARGETDIR=\"{targetDir}\" /qn";
576
577 var proc = Process.Start("msiexec.exe", args);
578 proc.WaitForExit(5000);
src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs
+1 -1
@@ -332,7 +332,7 @@ namespace WixToolsetTest.Sdk
332 var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
333 {
334 MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath),
335 - $"-p:PdbOutputDir={pdbFolder}",
335 + MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "PdbOutputDir", pdbFolder),
336 "-p:SuppressValidation=true"
337 });
338 result.AssertSuccess();