From 3c55e9af892b36e891ba0cd576ee20fa9d6af63d Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Tue, 2 Aug 2022 17:04:51 +0200 Subject: [PATCH] Avoid `Environment.SpecialFolder.ApplicationData` (#188) * Don't use ApplicationData for config file on UNIX When running on NET6 (VSMac installer), SpecialFolder.ApplicationData returns nothing, resulting in a relative path being used for the config file. So, just switch to use UserProfile, to which we append .config for the well known, and expected, place for the config file. Example testing with Mono's `csharp` command: $ csharp Mono C# Shell, type "help;" for help Enter statements below. csharp> Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) "/Users/jopepper/.config" csharp> Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) "/Users/jopepper" Co-authored-by: Jonathan Peppers --- src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkUnix.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkUnix.cs b/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkUnix.cs index f21bc65..c43b8ea 100644 --- a/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkUnix.cs +++ b/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkUnix.cs @@ -223,8 +223,7 @@ private static string UnixConfigPath { get { var p = AppDomain.CurrentDomain.GetData (GetUnixConfigDirOverrideName)?.ToString (); if (string.IsNullOrEmpty (p)) { - p = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData); - p = Path.Combine (p, "xbuild"); + p = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), ".config", "xbuild"); } return Path.Combine (p, "monodroid-config.xml"); }