Skip to content

Build of MAUI app fails if NuGet package contains references #11364

@AntonKosenkoPro

Description

@AntonKosenkoPro

Description

We want to hide our private libraries from IntelliSense for our customers. We followed the instructions from the following guide: Multiple assemblies in one package. This solution works in pure net7.0 apps, but leads to build errors on MAUI apps.

Steps to Reproduce

I prepared a sample repo to demonstrate this issue: https://github.com/AntonKosenkoDX/nuget-refs.

To build this project, please run the build script or execute the following commands:

dotnet build MyUtilities/MyUtilities.csproj
dotnet build MyLib/MyLib.csproj
nuget pack MyNuget/MyNuget.nuspec -OutputDirectory MyNuget/

dotnet build MyApp/MyApp.csproj
dotnet build MyConsoleApp/MyConsoleApp.csproj

You will see that the pure NET7 project is built without errors and it's IntelliSense shows only members from MyLib. Members from MyUtilities are not shown. This behavior is expected.

However, an attempt to build MyApp (MAUI application) results with the following error:

 error XAGJS7028: System.IO.FileNotFoundException: Could not load assembly 'MyUtilities, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile? 

Link to public reproduction project repository

https://github.com/AntonKosenkoDX/nuget-refs

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

All

Did you find any workaround?

No

Relevant log output

/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028: System.IO.FileNotFoundException: Could not load assembly 'MyUtilities, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile? [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028: File name: 'MyUtilities.dll' [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:line 245 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:line 191 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Mono.Cecil.MetadataResolver.Resolve(TypeReference type) in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/MetadataResolver.cs:line 110 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Mono.Cecil.ModuleDefinition.Resolve(TypeReference type) in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/ModuleDefinition.cs:line 762 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Mono.Cecil.TypeReference.Resolve() in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/TypeReference.cs:line 278 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Java.Interop.Tools.Cecil.TypeDefinitionCache.Resolve(TypeReference typeReference) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionCache.cs:line 20 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Java.Interop.Tools.Cecil.TypeDefinitionRocks.GetBaseType(TypeDefinition type, IMetadataResolver resolver) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionRocks.cs:line 23 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Java.Interop.Tools.Cecil.TypeDefinitionRocks.GetTypeAndBaseTypes(TypeDefinition type, IMetadataResolver resolver)+MoveNext() in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionRocks.cs:line 40 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Java.Interop.Tools.Cecil.TypeDefinitionRocks.IsSubclassOf(TypeDefinition type, String typeName, IMetadataResolver resolver) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionRocks.cs:line 94 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Java.Interop.Tools.JavaCallableWrappers.JavaTypeScanner.AddJavaTypes(List`1 javaTypes, TypeDefinition type) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/JavaTypeScanner.cs:line 58 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Java.Interop.Tools.JavaCallableWrappers.JavaTypeScanner.GetJavaTypes(IEnumerable`1 assemblies, IAssemblyResolver resolver) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/JavaTypeScanner.cs:line 48 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Xamarin.Android.Tasks.GenerateJavaStubs.Run(DirectoryAssemblyResolver res) [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    at Xamarin.Android.Tasks.GenerateJavaStubs.RunTask() [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Common.targets(1476,3): error XAGJS7028:    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 [/Users/antonkosenko/work/nuget-refs/MyApp/MyApp.csproj::TargetFramework=net7.0-android]

Metadata

Metadata

Assignees

No one assigned

    Labels

    partnerIssue or Request from a partner teamplatform/androids/needs-attentionIssue has more information and needs another lookt/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions