Skip to content

Unable to get the current directory from application in release mode. #2416

Closed

Description

@jeff-tenhave

Steps to Reproduce

  1. Create a Xamarin Android project. Configure it to build in release mode with the following options:
  • Everything unchecked exception AOT Compilation
  • Linking: Sdk Assemblies Only
  1. Log one of the following values to the console:
  • Directory.GetCurrentDirectory()
  • Assembly.GetExecutingAssembly().Location
  1. Run the application.

Expected Behavior

The directory that the application is running in is logged to the console.

Actual Behavior

The device root directory is logged to the console.

Version Information

Microsoft Visual Studio Enterprise 2017 (2)
Version 15.7.5
VisualStudio.15.Release/15.7.5+27703.2042
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools 00369-60000-00001-AA912
Microsoft Architecture Diagrams and Analysis Tools

Visual C++ 2017 00369-60000-00001-AA912
Microsoft Visual C++ 2017

Application Insights Tools for Visual Studio Package 8.12.10405.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017 15.0.40625.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services 15.7.31476
Provides languages services for ASP.NET Core Razor.

Azure App Service Tools v3.0.0 15.0.40608.0
Azure App Service Tools v3.0.0

C# Tools 2.8.3-beta6-63029-08. Commit Hash: e9a3a6c0ba5b1fde8b1fff964bdfb3fb768ee2eb
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service 2.0
JavaScript Language Service

JavaScript Project System 2.0
JavaScript Project System

JavaScript UWP Project System 2.0
JavaScript UWP Project System

Merq 1.1.19-rc (a4ffc1b)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Continuous Delivery Tools for Visual Studio 0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio 4.10.5-pre (ab58725)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools 15.1.61804.210
Microsoft SQL Server Data Tools

TypeScript Tools 15.7.20419.2003
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 2.8.3-beta6-63029-08. Commit Hash: e9a3a6c0ba5b1fde8b1fff964bdfb3fb768ee2eb
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.1 for F# 4.1 15.7.0.0. Commit Hash: 173513e369ffb7a1c4d5dccf83696d9aac2ab2d0.
Microsoft Visual F# Tools 10.1 for F# 4.1

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Spell Check Everywhere VSSpellCheckEverywhere
An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Spell Checker VSSpellChecker
An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Tools for Universal Windows Apps 15.0.27703.2042
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

Web Extension Pack 2017 15.0.2
The easiest way to set up Visual Studio for the ultimate web development experience.

Windows Machine Learning Generator Extension 1.0
Windows Machine Learning Visual Studio Extension Detailed Info

Xamarin 4.10.10.2 (35a01d8dc)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 4.12.1 (f3257e429)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK 8.3.3.2 (HEAD/dffc59120)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK 11.12.0.4 (64fece5)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Activity

  1. added this to the far future milestone on Nov 9, 2018
  2. grendello commented on Nov 9, 2018

    @grendello
    Contributor

    @jeff-tenhave this is not a bug, I'm afraid. Android sets the current working directory (CWD) of an app to the root of the device. If you want to get the application data directory you need to use the Context class properties (such as DataDir, FilesDir, ExternalCacheDir) to find the location of various directories related to the application. If you want to learn the location where the app is "installed", you can either retrieve the HOME environment variable (it's set by Xamarin.Android runtime before loading the managed code, based on information passed to us by Android) or use the Environment.GetFolderPath (Environment.SpecialFolder.Personal) BCL call.

  3. ghost locked as resolved and limited conversation to collaborators on Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions