maui: Directory Not Found of DLL from .Net MAUI class library in folder Debug\net6.0-android\android-x64

Description

When I launch my .NET Maui App I get an error that it cannot find my DLL of the .Net Maui Class library in my solution that is referenced by by .Net Maui App.

It tries to find this DLL in the folder: bin\Debug\net6.0-android\android-x64 from my Maui Class Library.

The android-x64 folder does not exist.

My DLL exist but in the folder: bin\Debug\net6.0-android\

VS Version 17.4.0 Preview 2.0

The complete error:

Error XAPRAS7023: System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\GIT\Maui\test\MauiApp2\MauiLib1\bin\Debug\net6.0-android\android-x64\MauiLib1.dll'.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share) at Xamarin.Android.Tasks.MonoAndroidHelper.HasMonoAndroidReference(ITaskItem assembly) at Xamarin.Android.Tasks.ProcessAssemblies.SetMetadataForAssemblies(List1 output, Dictionary2 symbols) at Xamarin.Android.Tasks.ProcessAssemblies.RunTask() at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17 (99, 6)

VS info:

Microsoft Visual Studio Enterprise 2022 Version 17.4.0 Preview 2.0 VisualStudio.17.Preview/17.4.0-pre.2.0+32912.340 Microsoft .NET Framework Version 4.8.09037

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools 00476-80000-00000-AA617 Microsoft Architecture Diagrams and Analysis Tools

Visual C++ 2022 00476-80000-00000-AA617 Microsoft Visual C++ 2022

ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools

ASA Service Provider 1.0

ASP.NET and Web Tools 17.4.210.756 ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.4.210.756 Azure App Service Tools v3.0.0

Azure Data Lake Tools for Visual Studio 2.6.5000.0 Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 17.4.210.756 Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.6.5000.0 Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 4.4.0-2.22430.14+2f760738cb92f32f50c981b68ba04ac3c8b7ee48 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.

Dotfuscator Community Edition 6.5.0+76d4669002 PreEmptive Protection - Dotfuscator CE

Extensibility Message Bus 1.4.1 (main@2ee106a) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

File Differ 2.0.28 The easiest way to diff two files directly in Solution Explorer

GitExtensions 1.0 Git Extensions is a graphical user interface for Git that allows you to control Git without using the command-line

ILSpy.AddIn 1.0 Integration of the ILSpy Decompiler into Visual Studio.

IncrediBuild Build Acceleration 1.6.0.2 IncrediBuild effectively reduces compilation and development times by up to 90%.

Microsoft Azure Hive Query Language Service 2.6.5000.0 Language service for Hive query

Microsoft Azure Stream Analytics Language Service 2.6.5000.0 Language service for Azure Stream Analytics

Microsoft Azure Tools for Visual Studio 2.9 Support for Azure Cloud Services projects

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

Mono Debugging for Visual Studio 17.4.19 (8c0a575) Support for debugging Mono processes with Visual Studio.

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

Razor (ASP.NET Core) 17.0.0.2243101+64a0117763b8eb085c75bdb80329e16e5a2c65a5 Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools 17.0.62207.28050 Microsoft SQL Server Data Tools

SQLite & SQL Server Compact Toolbox 4.8 SQLite & SQL Server Compact Toolbox adds scripting, import, export, rename, query execution and much more to SQL Server Compact & SQLite Data Connections.

StylerPackage Extension 1.0 StylerPackage Visual Stuido Extension Detailed Info

Switch Startup Project 4.2.76 Provides a toolbar dropdown box to switch between startup projects.

Syncfusion ASP.NET Core Project Templates 20.1.0.47 Provides project templates for creating an ASP.NET Core Web Application using Syncfusion ASP.NET Core components.

Syncfusion ASP.NET Core Project Templates 16.1.0.32 Provides project templates for creating an ASP.NET Core Web Application using Syncfusion ASP.NET Core components.

Syncfusion ASP.NET MVC Project Templates 17.1.0.32 Provides project templates for creating ASP.NET MVC Web Applications using Syncfusion components.

Syncfusion Reference Manager 20.2.0.43 A useful add-in for adding and migrating Syncfusion Assembly References for Windows Forms, WPF, and Silverlight projects.

Syncfusion UWP Project Templates 20.1.0.47 Project to create an Universal Windows Application using Syncfusion Products.

Syncfusion WPF Project Templates 20.2.0.43 Provides Project/Item Templates to add Syncfusion WPF Project/Item along with corresponding configurations.

Syncfusion Xamarin Project Templates 20.2.0.43 A multi-project template for building iOS, Android, and Windows apps using Syncfusion Xamarin components.

Syncfusion Xamarin Toolbox 20.2.0.43 Syncfusion Essential Studio for Xamarin Toolbox Visual Studio extension.

Syncfusion.VSExtension.Troubleshooter 20.2.0.43 Add-in for Troubleshooting the Syncfusion projects.

SyncfusionCodeGeneratorMenuCommand Extension 16.1.0.32 SyncfusionCodeGeneratorMenuCommand Visual Studio Extension Detailed Info

SyncfusionMenu Extension 20.2.0.43 SyncfusionMenu Visual Studio Extension Detailed Info

Syntax Visualizer 1.0 An extension for visualizing Roslyn SyntaxTrees.

Test Adapter for Boost.Test 1.0 Enables Visual Studio’s testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test 1.0 Enables Visual Studio’s testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

ToolWindowHostedEditor 1.0 Hosting json editor into a tool window

TypeScript Tools 17.0.10901.2002 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.4.0-2.22430.14+2f760738cb92f32f50c981b68ba04ac3c8b7ee48 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 17.4.0-beta.22429.6+22514929f2e903ea8c14947bea7c2b242886e1ee Microsoft Visual F# Tools

Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio.

VisualStudio.DeviceLog 1.0 Information about my package

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

VSPackage Extension 1.0 VSPackage Visual Studio Extension Detailed Info

Xamarin 17.4.0.168 (main@f46a973) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 17.4.0.107 (remotes/origin/d17-4@d549bb251b) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 17.4.2 (c457c97) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 13.0.99.81 (main/7c9c24b) Xamarin.Android Reference Assemblies and MSBuild support. Mono: dffa5ab Java.Interop: xamarin/java.interop/main@2c8b0a8f SQLite: xamarin/sqlite/3.39.2@40e8743 Xamarin.Android Tools: xamarin/xamarin-android-tools/main@29f11f2

Xamarin.iOS and Xamarin.Mac SDK 15.13.0.65 (409c80dd9) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Steps to Reproduce

  1. Create new .Net Maui App
  2. Select in Android simulator (tested with android 9, 10, 11 and 12)
  3. Start this new .Net Maui App works
  4. Add .Net Maui Class Library
  5. Add project reference in .Net Maui App to .Net Maui Class Library
  6. Restart .Net Maui App

Now you get the error.

Link to public reproduction project repository

https://github.com/TomLac/Maui-Error-System.IO.DirectoryNotFoundException.git

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

android 12

Did you find any workaround?

No response

Relevant log output

Error XAPRAS7023: System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\GIT\Maui\test\MauiApp2\MauiLib1\bin\Debug\net6.0-android\android-x64\MauiLib1.dll'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Xamarin.Android.Tasks.MonoAndroidHelper.HasMonoAndroidReference(ITaskItem assembly)
   at Xamarin.Android.Tasks.ProcessAssemblies.SetMetadataForAssemblies(List`1 output, Dictionary`2 symbols)
   at Xamarin.Android.Tasks.ProcessAssemblies.RunTask()
   at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17 (99, 6)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 17
  • Comments: 35 (4 by maintainers)

Most upvoted comments

We’ve moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Work-around

Here are the steps to follow:

  1. in the Solution Items folder of your solution, create a batch file named WorkAround10150.bat with a line like this for each project that your MAUI-App depends on (both .NET6 and MAUI library projects work, just note the different paths):
xcopy ..\<Net6LibName>\bin\Debug\net6.0\*.* ..\<Net6LibName>\bin\Debug\net6.0\android-x64\*.* /Y
xcopy ..\<MauiLibName>\bin\Debug\net6.0-android\*.* ..\<MauiLibName>\bin\Debug\net6.0-android\android-x64\*.* /Y
  1. right-click the MAUI-App project in the solution explorer and pick [Properties]
  2. navigate to the Build|Events section and enter this line as a Pre-build event:
call ..\WorkAround10150.bat

Now, the MAUI-App works nicely with Android again 😃

doesn’t help. we are completely blocked with our android development. would be nice if a fix lands before .NET 8

Before .NET 8? We need this yesterday! =)

same here

@hartez @PureWeen

@TomLac if you add

<IsRidAgnostic Condition="'$(TargetPlatformIdentifier)' == 'android' and '$(OutputType)' == 'Library'">true</IsRidAgnostic>

to your csproj file does that fix?

doesn’t help. we are completely blocked with our android development. would be nice if a fix lands before .NET 8

Untitled-1

I’ just tried 17.4.0 Preview 2.1 and the problem disappeard.

I’m having the exact same issue (after updating today to the newly released Visual Studio version 17.4.0 preview 2.0), except that the compiled assemblies are missing in the net6.0-android\android-arm64. They do exist in the net6.0-android folder. This is blocking development as I’m now no longer able to start/debug my application! Tried the <IsRidAgnostic /> change proposed above, but that didn’t make any difference. Though I’m not sure if this is a .NET MAUI related or a Visual Studio related issue. After installing the stable version of Visual Studio (version 17.3.4) I’m able again to debug the application. So that is for now a work-around for me.

Also seeing the problem. We really need a solution for this as it effectively blocks our development.

@TomLac if you add

<IsRidAgnostic Condition="'$(TargetPlatformIdentifier)' == 'android' and '$(OutputType)' == 'Library'">true</IsRidAgnostic>

to your csproj file does that fix?

@VWilcox2000 thanks for the nice workaround improvement👍

Thanks for the post-build event idea above, @Dbquity. Not sure why they removed the post build edit with all the helpful macros included, but here is a universal build event that will work for any project. I had to add it to like 7 .net standard 2.1 projects:

   if NOT EXIST $(ProjectDir)$(OutDir)android-x64 md $(ProjectDir)$(OutDir)android-x64
   xcopy $(ProjectDir)$(OutDir) $(ProjectDir)$(OutDir)android-x64 /y

First time I’ve been able to get a MAUI project loaded into ANY emulator since last week… at least the Android error texts give some clue.