dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.83k stars 1.67k forks source link

error XAPRAS7023: System.IO.DirectoryNotFoundException: Could not find a part of the path \AndroidLib1\bin\Debug\net8.0-android\android-x64\AndroidLib1.dll #23382

Open ma81xx opened 4 days ago

ma81xx commented 4 days ago

Description

When I deploy the project to device/emulator I get the XAPRAS7023 DirectoryNotFoundException error.

The problem seems the https://github.com/dotnet/maui/issues/10150, but I get it in more recent update, in net8.0-android, VS 2022 17.10.3, Android SDK 34, Android Command line tools 11.0, Android SDK Platform tools 35.0.1 Android SDK Build tools 34.0.0, Android emulator 34.1.19

dotnet workload list ID Manifest versions Installation source android 34.0.95/8.0.100 VS 17.10.35013.160 aspire 8.0.0/8.0.100 VS 17.10.35013.160 maui-windows 8.0.40/8.0.100 VS 17.10.35013.160 maccatalyst 17.2.8053/8.0.100 VS 17.10.35013.160 ios 17.2.8053/8.0.100 VS 17.10.35013.160

I already found that the problem was due to a double project reference to a library in a .csproj. It was born in a bad merge.

I think this can be useful to someone else that falls in a similar problem or to the developers of Android Build process.

Stack trace:

App04Bug -> C:\Users\user\source\repos\App04Bug\App04Bug\App04Bug\bin\Debug\net8.0-android\App04Bug.dll C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(123,5): error XAPRAS7023: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\user\source\repos\App04Bug\App04Bug\AndroidLib1\bin\Debug\net8.0-android\android-x64\AndroidLib1.dll'. C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(123,5): error XAPRAS7023: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(123,5): error XAPRAS7023: 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) C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(123,5): error XAPRAS7023: at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(123,5): error XAPRAS7023: at Xamarin.Android.Tasks.MonoAndroidHelper.HasMonoAndroidReference(ITaskItem assembly) C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(123,5): error XAPRAS7023: at Xamarin.Android.Tasks.ProcessAssemblies.SetMetadataForAssemblies(List1 output, Dictionary2 symbols) C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(123,5): error XAPRAS7023: at Xamarin.Android.Tasks.ProcessAssemblies.RunTask() C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(123,5): error XAPRAS7023: 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 25

Steps to Reproduce

  1. Create a new "Android Application" project (not ".NET MAUI App")
  2. Create a new "Android Class Library" project
  3. Add a reference from App to Library
  4. Edit App csproj file and duplicate the ProjectReference row
  5. Build and Deploy => so I get Error instead of deployment

Link to public reproduction project repository

No response

Version with bug

Unknown/Other

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

VS 2022 17.10.3, net8.0-android, android 34

Did you find any workaround?

The problem was due to a double project reference to a library in a .csproj

Relevant log output

No response

github-actions[bot] commented 4 days ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

RoiChen001 commented 1 day ago

This problem cannot be reproduced at Android platform on the latest 17.10.3(8.0.61).

ma81xx commented 23 hours ago

Reproduction project: https://github.com/ma81xx/App04Bug Git clone, open solution in VS2022 (17.10.3), build App04Bug project

The problem is due to the duplicated project reference at https://github.com/ma81xx/App04Bug/blob/master/App04Bug/App04Bug.csproj#L14