Skip to content

Commit

Permalink
Avoid Environment.SpecialFolder.ApplicationData (#188)
Browse files Browse the repository at this point in the history
* 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 <jonathan.peppers@microsoft.com>
  • Loading branch information
Rodrigo Moya and jonathanpeppers committed Aug 2, 2022
1 parent 0d55472 commit 3c55e9a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkUnix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ void AddToList (string path)
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");
}
Expand Down

0 comments on commit 3c55e9a

Please sign in to comment.