maui icon indicating copy to clipboard operation
maui copied to clipboard

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

Open TomLac opened this issue 3 years ago • 26 comments

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)

TomLac avatar Sep 15 '22 17:09 TomLac

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.

ghost avatar Sep 15 '22 18:09 ghost

@TomLac if you add

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

to your csproj file does that fix?

PureWeen avatar Sep 15 '22 22:09 PureWeen

Same question for @arivoir

hartez avatar Sep 15 '22 22:09 hartez

Which csproj, the lib or the app?

arivoir avatar Sep 15 '22 23:09 arivoir

Tried both, didn't work

arivoir avatar Sep 15 '22 23:09 arivoir

Same problem after updating to VS Version 17.4.0 Preview 2.0. dotnet --version 6.0.400

sevakraynov avatar Sep 16 '22 06:09 sevakraynov

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

JkPersson avatar Sep 16 '22 06:09 JkPersson

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.

jBijsterboschNL avatar Sep 16 '22 09:09 jBijsterboschNL

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

nor0x avatar Sep 16 '22 12:09 nor0x

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! =)

IgorKravchenko10 avatar Sep 16 '22 17:09 IgorKravchenko10

for everyone blocked and using Visual Studio. You could still use the CLI commands to do stuff as a workaround

nor0x avatar Sep 16 '22 18:09 nor0x

same problem here, it is Android issue only as of now for me, Windows desktop app works fine

RorroRojas3 avatar Sep 16 '22 22:09 RorroRojas3

same problem here, did a rollback to preview 1 (nice feature btw)

profix898 avatar Sep 16 '22 22:09 profix898

Please resolve this. 👍 In this case the rollback works but another error which prevents iOS testing/release, the rollback did not work: https://developercommunity.visualstudio.com/t/Failed-to-pair-to-Mac-with-error-Could/10138259?entry=problem

SophisticatedConsulting avatar Sep 17 '22 09:09 SophisticatedConsulting

Same here.

Chuckh008 avatar Sep 17 '22 20:09 Chuckh008

Same issue here. if there's no promise it'll be resolved soon I'll try a roll-back myself as I'm blocked by this as well.

PascalDesmet avatar Sep 18 '22 14:09 PascalDesmet

Rollback via VS installer helped me, thanks!

Dreamescaper avatar Sep 18 '22 14:09 Dreamescaper

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 :-)

Dbquity avatar Sep 18 '22 22:09 Dbquity

I also get this error when use VS17.4.0 preview2.0. I try to use VS17.3.3, it is ok

xtuzy avatar Sep 19 '22 10:09 xtuzy

I also get this error when updating the VS 2022 Professional Preview version to 17.4.0 preview 2.0... is there any workaround for this...The workaround mentioned in this comment history not works for me

Ahamed-Ali avatar Sep 19 '22 12:09 Ahamed-Ali

I also get this error when updating the VS 2022 Professional Preview version to 17.4.0 preview 2.0... is there any workaround for this...The workaround mentioned in this comment history not works for me

@Ahamed-Ali are you referring to the build-event workaround? If so, can you share the error, you get?

Dbquity avatar Sep 19 '22 12:09 Dbquity

Same here, rolled back to preview 1 and it started working.

r-work avatar Sep 19 '22 12:09 r-work

image Hi @Dbquity , When I referring to the build-event workaround .. I got the above error

Ahamed-Ali avatar Sep 19 '22 12:09 Ahamed-Ali

@Ahamed-Ali that is likely because the directory structure of your solution is not exactly the same as mine, which means that the .bat-file does not get executed. To fix it you either

  • don't need the ..\ in the call command, if your MAUI-App lives directly in the solution directory, or
  • need a ..\..\, if your MAUI-App is deeper nested

To test this, I recommend opening a command prompt in the directory of the MAUI-App and figure out what you need to type to get the WorkAround10150.bat called. Once you succeed in getting it called, you may see similar issues with the occurrences of ..\ inside the .bat - depending on where exactly you store the library projects that the app depends on.

Feel free to ask, if it still does not work :-)

Dbquity avatar Sep 19 '22 13:09 Dbquity

Has anyone tried the new VS update? 17.4.0 Preview 2.1 released September 20th

vallgrenerik avatar Sep 21 '22 06:09 vallgrenerik

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

flitta avatar Sep 21 '22 06:09 flitta

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 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.

Mee too. I believe the provided workaround could help us. My .bat file is the following: xcopy ..\Model\bin\Debug\net6.0\*.* ..\Model\bin\Debug\net6.0\android-x64\*.* /Y xcopy ..\Model\bin\Debug\net6.0-android\*.* ..\Model\bin\Debug\net6.0-android\android-x64\*.* /Y new line added by me to copy the dependencies to arm64 folder xcopy ..\Model\bin\Debug\net6.0-android\*.* ..\Model\bin\Debug\net6.0-android\android-arm64\*.* /Y

this way I can debug in emulator and physical devices

Although, I am tired of dealing with Preview errors, for me, the best setup for now is using the stable version of the Visual Studio (17.3.4) and using the 6.0.400 not the 6.0.401 (just rename 6.0.401 and others if you have it).

Ewerton avatar Sep 23 '22 01:09 Ewerton

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 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.

Mee too. I believe the provided workaround could help us. My .bat file is the following: xcopy ..\Model\bin\Debug\net6.0\*.* ..\Model\bin\Debug\net6.0\android-x64\*.* /Y xcopy ..\Model\bin\Debug\net6.0-android\*.* ..\Model\bin\Debug\net6.0-android\android-x64\*.* /Y new line added by me to copy the dependencies to arm64 folder xcopy ..\Model\bin\Debug\net6.0-android\*.* ..\Model\bin\Debug\net6.0-android\android-arm64\*.* /Y

this way I can debug in emulator and physical devices

Although, I am tired of dealing with Preview errors, for me, the best setup for now is using the stable version of the Visual Studio (17.3.4) and using the 6.0.400 not the 6.0.401 (just rename 6.0.401 and others if you have it).

Microsoft Help Now !!!!!

MarcoErlwein avatar Sep 26 '22 12:09 MarcoErlwein

I just tried 17.4.0 Preview 2.1 and the issue fixed

Ahamed-Ali avatar Sep 26 '22 12:09 Ahamed-Ali

Hi @TomLac. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Sep 26 '22 15:09 ghost