diff options
| author | Rob Mensching <rob@firegiant.com> | 2023-03-23 14:36:09 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2023-03-23 21:48:29 -0700 |
| commit | 38fe36a2072b1abde87b52643e43a3d7ddf2a2f5 (patch) | |
| tree | 96289f7d4ab6574bb07fee5e61bf6c1b7fcc4b12 /src/internal/WixInternal.TestSupport/MsbuildUtilities.cs | |
| parent | 2426cee1fc8c6e809c5a37abdf9d722a6e8e3a33 (diff) | |
| download | wix-38fe36a2072b1abde87b52643e43a3d7ddf2a2f5.tar.gz wix-38fe36a2072b1abde87b52643e43a3d7ddf2a2f5.tar.bz2 wix-38fe36a2072b1abde87b52643e43a3d7ddf2a2f5.zip | |
Always add space to to test folder to flush out such bugs
Diffstat (limited to 'src/internal/WixInternal.TestSupport/MsbuildUtilities.cs')
| -rw-r--r-- | src/internal/WixInternal.TestSupport/MsbuildUtilities.cs | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/internal/WixInternal.TestSupport/MsbuildUtilities.cs b/src/internal/WixInternal.TestSupport/MsbuildUtilities.cs index 5560f993..95b3e37b 100644 --- a/src/internal/WixInternal.TestSupport/MsbuildUtilities.cs +++ b/src/internal/WixInternal.TestSupport/MsbuildUtilities.cs | |||
| @@ -27,7 +27,7 @@ namespace WixToolsetTest.Sdk | |||
| 27 | // Node reuse means that child msbuild processes can stay around after the build completes. | 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. | 28 | // Under that scenario, the root msbuild does not reliably close its streams which causes us to hang. |
| 29 | "-nr:false", | 29 | "-nr:false", |
| 30 | $"-bl:{Path.ChangeExtension(projectPath, ".binlog")}" | 30 | MsbuildUtilities.GetQuotedSwitch(buildSystem, "bl", Path.ChangeExtension(projectPath, ".binlog")) |
| 31 | }; | 31 | }; |
| 32 | 32 | ||
| 33 | if (arguments != null) | 33 | if (arguments != null) |
| @@ -59,36 +59,35 @@ namespace WixToolsetTest.Sdk | |||
| 59 | } | 59 | } |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | public static string GetQuotedPropertySwitch(BuildSystem buildSystem, string propertyName, string valueToQuote) | 62 | public static string GetQuotedSwitch(BuildSystem _, string switchName, string switchValue) |
| 63 | { | 63 | { |
| 64 | switch (buildSystem) | 64 | // If the value ends with a backslash, escape it. |
| 65 | if (switchValue?.EndsWith("\\") == true) | ||
| 65 | { | 66 | { |
| 66 | case BuildSystem.DotNetCoreSdk: | 67 | switchValue += @"\"; |
| 67 | { | 68 | } |
| 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 | } | ||
| 73 | 69 | ||
| 74 | return $"-p:{propertyName}=\\\"{valueToQuote}\\\""; | 70 | return $"-{switchName}:\"{switchValue}\""; |
| 75 | } | 71 | } |
| 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 | } | ||
| 84 | 72 | ||
| 85 | return $"-p:{propertyName}=\"{valueToQuote}\""; | 73 | public static string GetQuotedPropertySwitch(BuildSystem buildSystem, string propertyName, string propertyValue) |
| 86 | } | 74 | { |
| 87 | default: | 75 | // If the value ends with a backslash, escape it. |
| 88 | { | 76 | if (propertyValue?.EndsWith("\\") == true) |
| 89 | throw new NotImplementedException(); | 77 | { |
| 90 | } | 78 | propertyValue += @"\"; |
| 91 | } | 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}"; | ||
| 92 | } | 91 | } |
| 93 | 92 | ||
| 94 | public static IEnumerable<string> GetToolCommandLines(MsbuildRunnerResult result, string toolName, string operation, BuildSystem buildSystem) | 93 | public static IEnumerable<string> GetToolCommandLines(MsbuildRunnerResult result, string toolName, string operation, BuildSystem buildSystem) |
