Commit e618e00
authored
[Xamarin.Android.Tools.AndroidSdk] Fix quotes in %PATH% or %PATHEXT% (#112)
Fixes: https://developercommunity.visualstudio.com/t/illegal-character-exception-in-xamarinandroid-afte/1363149
In 16.9 we are getting some reports of:
(_ResolveSdks target) ->
error XARSD7004: System.ArgumentException: Illegal characters in path.
error XARSD7004: at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
error XARSD7004: at System.IO.Path.Combine(String path1, String path2)
error XARSD7004: at Xamarin.Android.Tools.ProcessUtils.<FindExecutablesInDirectory>d__9.MoveNext()
error XARSD7004: at Xamarin.Android.Tools.ProcessUtils.<FindExecutablesInPath>d__8.MoveNext()
error XARSD7004: at Xamarin.Android.Tools.AndroidSdkBase.<GetAllAvailableAndroidNdks>d__73.MoveNext()
error XARSD7004: at Xamarin.Android.Tools.AndroidSdkWindows.<GetAllAvailableAndroidNdks>d__43.MoveNext()
error XARSD7004: at Xamarin.Android.Tools.AndroidSdkBase.GetValidNdkPath(String ctorParam)
error XARSD7004: at Xamarin.Android.Tools.AndroidSdkBase.Initialize(String androidSdkPath, String androidNdkPath, String javaSdkPath)
error XARSD7004: at Xamarin.Android.Tools.AndroidSdkWindows.Initialize(String androidSdkPath, String androidNdkPath, String javaSdkPath)
error XARSD7004: at Xamarin.Android.Tools.AndroidSdkInfo..ctor(Action`2 logger, String androidSdkPath, String androidNdkPath, String javaSdkPath)
error XARSD7004: at Xamarin.Android.Tasks.MonoAndroidHelper.RefreshAndroidSdk(String sdkPath, String ndkPath, String javaPath, TaskLoggingHelper logHelper)
error XARSD7004: at Xamarin.Android.Tasks.ResolveSdks.RunTask()
error XARSD7004: at Xamarin.Android.Tasks.AndroidTask.Execute()
It appears this is simply a call like this failing:
Path.Combine ("foo", "\"")
Path.Combine ("\"", "foo")
The most likely reason for certain customers to get this exception is
because an environment variable contains quotes, e.g.
rem Windows CMD.EXE
set PATH='…'
On Windows+CMD.EXE, the `'` (or `"`) is *not* needed, even if the
value has spaces:
rem Can cause Pain and Suffering™
set PATH="C:\This Directory Has Spaces;%PATH%"
rem Good and Proper™
set PATH=C:\This Directory Has Spaces;%PATH%
I could reproduce this in a test by setting `%PATH%` or `%PATHEXT%`
to invalid names.
For `%PATH%`, I could simply add a `Directory.Exists()` check in the
place that makes sense. However, I think a `try`/`catch` of
`ArgumentException` is the only way to handle `%PATHEXT%`? I had to
put this in two places where the new test found an issue.1 parent 554d45a commit e618e00
File tree
3 files changed
+60
-4
lines changed- src/Xamarin.Android.Tools.AndroidSdk
- Sdks
- tests/Xamarin.Android.Tools.AndroidSdk-Tests
3 files changed
+60
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
176 | 178 | | |
177 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
178 | 185 | | |
179 | 186 | | |
180 | 187 | | |
| |||
Lines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
296 | | - | |
297 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
298 | 303 | | |
299 | 304 | | |
300 | 305 | | |
| |||
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
149 | 193 | | |
150 | 194 | | |
151 | 195 | | |
| |||
0 commit comments