Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[net9.0] Not able to load net9 branch on VS Internal preview can't find libZipSharp #20752

Closed
rmarinho opened this issue Feb 21, 2024 · 1 comment
Assignees
Labels
partner/android Issues for the Android SDK platform/android 🤖 t/bug Something isn't working

Comments

@rmarinho
Copy link
Member

Description

When trying to run the current version of android on the net9 branch on VS internal preview with cake script I get a error with
libZipSharp.

Steps to Reproduce

Checkt net9 branch

dotnet cake --target=VS

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

No response

Did you find any workaround?

No response

Relevant log output

XARLP7028
System.IO.FileNotFoundException: Could not load file or assembly 'libZipSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=276db85bc4e20efc' or one of its dependencies. The system cannot find the file specified.File name: 'libZipSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=276db85bc4e20efc'   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(IDictionary`2 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments, ICollection`1 proguardConfigFiles)   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.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 25WRN: Assembly binding logging is turned OFF.To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.Note: There is some performance penalty associated with assembly bind failure logging.To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Graphics (Graphics\src\Graphics)
C:\repos\dotnet\maui\bin\dotnet\packs\Microsoft.Android.Sdk.Windows\34.99.0-preview.2.174\tools\Xamarin.Android.EmbeddedResource.targets
39
@jonathanpeppers
Copy link
Member

This is fixed by: dotnet/android#8738

We are waiting on CI to merge.

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Feb 21, 2024
Context: dotnet/maui#20752

We think this might catch problems specific to .NET framework going forward.
jonathanpeppers added a commit to dotnet/android that referenced this issue Feb 21, 2024
Fixes: dotnet/maui#20752

Context: d1ba2cc
Context: dotnet/android-tools@34e98e2
Context: #8746

`dotnet build` (.NET Core) ignores assembly versions.
`msbuild.exe` (.NET Framework) does not.

Enter d1ba2cc, which updates the `libZipSharp.dll` assembly version
from 3.0.0.0 to 3.1.1.0.  However, this change only impacted
`Xamarin.Android.Build.Tasks.dll`:

	% monodis --assemblyref bin/Release/lib/packs/Microsoft.Android.Sdk.Darwin/34.99.0/tools/Xamarin.Android.Build.Tasks.dll
	…
	11: Version=3.1.1.0
		Name=libZipSharp
		Flags=0x00000000

It did *not* impact `Microsoft.Android.Build.BaseTasks.dll`, as it
is built by `external/xamarin-android-tools` and was using a
`@(PackageReference)` for libZipSharp 3.0.0:

	% monodis --assemblyref bin/Release/lib/packs/Microsoft.Android.Sdk.Darwin/34.99.0/tools/Microsoft.Android.Build.BaseTasks.dll
	…
	5: Version=3.0.0.0
	        Name=libZipSharp
	        Flags=0x00000000

The resulting NuGet package only contains *one* `libZipSharp.dll`,
the 3.1.1.0 version (what `Xamarin.Android.Build.Tasks.dll` refs).

On PR builds and CI, everything was fine, because all the tests we
have use `dotnet build`, and .NET Core ignores assembly versions.

However, if you use *`msbuild.exe`* to invoke the tasks within
`Microsoft.Android.Build.BaseTasks.dll`, things fail:

	XARLP7028 System.IO.FileNotFoundException: Could not load file or assembly 'libZipSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=276db85bc4e20efc' or one of its dependencies.
	The system cannot find the file specified.File name: 'libZipSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=276db85bc4e20efc'
	   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(IDictionary`2 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments, ICollection`1 proguardConfigFiles)
	   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.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 25

Fix this by adding an `external/xamarin-android-tools.override.props`
file (dotnet/android-tools@34e98e2b) which imports
`Directory.Build.props`, which causes `$(LibZipSharpVersion)` to be
set so that the xamarin-android-tools build uses values provided by
xamarin-android.

TODO: #8746 adds a unit test for the
"build with `msbuild.exe`" scenario.
@github-actions github-actions bot locked and limited conversation to collaborators Mar 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
partner/android Issues for the Android SDK platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants