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
22.21k stars 1.75k forks source link

MAUI app template will not build due to LibZipSharp error VS Community 2022 Preview 3 #6254

Closed rsfitzii closed 2 years ago

rsfitzii commented 2 years ago

Description

When building a brand new "empty" MAUI app in VS 2022 Community Preview 3, the build fails with an error that compression method is not supported. This appears to happen during _ResolveProjectLibraryImports

Steps to Reproduce

Create a new MAUI app using the MAUI app template Build and deploy to Android (have tried APIs 28, 30 and 31) Build fails with XARLP7000: Xamarin.Tools.Zip.ZipException: Compression method not supported when trying to resolve library project imports

Version with bug

Release Candidate 1 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11, Android 12

Did you find any workaround?

Not yet

Relevant log output

1>        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.1.4\tools\Xamarin.Android.EmbeddedResource.targets(36,5): error XARLP7000: Xamarin.Tools.Zip.ZipException: Compression method not supported
1>        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.1.4\tools\Xamarin.Android.EmbeddedResource.targets(36,5): error XARLP7000:    at Xamarin.Tools.Zip.ZipArchive.AddStream(Stream stream, String archivePath, EntryPermissions permissions, CompressionMethod compressionMethod, Boolean overwriteExisting, Nullable`1 modificationTime) in /Users/runner/work/1/s/LibZipSharp/Xamarin.Tools.Zip/ZipArchive.cs:line 353
1>        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.1.4\tools\Xamarin.Android.EmbeddedResource.targets(36,5): error XARLP7000:    at Xamarin.Tools.Zip.ZipArchive.AddFile(String sourcePath, String archivePath, EntryPermissions permissions, CompressionMethod compressionMethod, Boolean overwriteExisting) in /Users/runner/work/1/s/LibZipSharp/Xamarin.Tools.Zip/ZipArchive.cs:line 417
1>        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.1.4\tools\Xamarin.Android.EmbeddedResource.targets(36,5): error XARLP7000:    at Xamarin.Android.Tasks.ZipArchiveEx.AddFileAndFlush(String filename, Int64 fileLength, String archiveFileName, CompressionMethod compressionMethod)
1>        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.1.4\tools\Xamarin.Android.EmbeddedResource.targets(36,5): error XARLP7000:    at Xamarin.Android.Tasks.ZipArchiveEx.AddFiles(String folder, String folderInArchive, CompressionMethod method)
1>        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.1.4\tools\Xamarin.Android.EmbeddedResource.targets(36,5): error XARLP7000:    at Xamarin.Android.Tasks.ZipArchiveEx.AddDirectory(String folder, String folderInArchive, CompressionMethod method)
1>        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.1.4\tools\Xamarin.Android.EmbeddedResource.targets(36,5): error XARLP7000:    at Xamarin.Android.Tasks.ResolveLibraryProjectImports.<>c__DisplayClass67_0.<CreateResourceArchive>b__0(String f)
1>        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.1.4\tools\Xamarin.Android.EmbeddedResource.targets(36,5): error XARLP7000:    at Microsoft.Android.Build.Tasks.Files.ArchiveZipUpdate(String target, Action`1 archiver) in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/Files.cs:line 94
1>        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.1.4\tools\Xamarin.Android.EmbeddedResource.targets(36,5): error XARLP7000:    at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(IDictionary`2 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
1>        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.1.4\tools\Xamarin.Android.EmbeddedResource.targets(36,5): error XARLP7000:    at Xamarin.Android.Tasks.ResolveLibraryProjectImports.RunTask()
1>        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.300-rc.1.4\tools\Xamarin.Android.EmbeddedResource.targets(36,5): error XARLP7000:    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
1>      Done executing task "ResolveLibraryProjectImports" -- FAILED.
drasticactions commented 2 years ago

@rsfitzii Are you able to build a net6.0-android application in general? Try making a new dotnet new android app and see if that deploys.

@jonathanpeppers do you have any ideas?

v-longmin commented 2 years ago

Verified not repro on VS 17.3.0 Preview 1.0 [32418.321.main]. Not repro with maui sample template project.

jonathanpeppers commented 2 years ago

Something might have gone wrong with NuGet downloading files. If someone hits this again, try deleting things in %userprofile%\.nuget\packages to see if that solves the issue.

rsfitzii commented 2 years ago

I will try that, thank you.

rsfitzii commented 2 years ago

I tried deleted .nuget/packages and recompiled but I received the same error as before.

I also tried creating a new plain .net 6 android app and that threw the same build error.

This seems to only be android specific because I can deploy the app to the windows emulator and it compiles and runs fine.

I know it must have something to do with my particular environment but so far I'm at a loss as to what it could be. I had this happen way back with vs 2022 preview 1, but was eventually able to get it working and then once I upgraded to preview 2 it's been broken. I keep thinking a new preview will fix it but it hasn't so I'm pretty sure it's not specifically to do with Visual Studio itself.

Thanks for all your suggestions, I will keep trying different tings until something works.

jonathanpeppers commented 2 years ago

@rsfitzii so you get the above error with:

dotnet new android
dotnet build -bl

If so, can you attach the msbuild.binlog file the above command produces? If it works, do the same with dotnet new maui.

rsfitzii commented 2 years ago

I'm sorry I should have been more specific. This error happens when I try to create and build the project in VS 2022 Preview (at the moment I'm up to preview 4).

If I run the dotnet new/build commands from the command line, I do NOT receive that error. Both "dotnet new android" and "dotnet new maui" will build successfully.

jonathanpeppers commented 2 years ago

So then we could try .NET framework MSBuild, such as:

"C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\MSBuild.exe" -restore -bl

(Check that file exists, your path could be different)

This would be how VS builds. Does that fail?

rsfitzii commented 2 years ago

That does NOT fail either. It completes with "build successful".

jonathanpeppers commented 2 years ago

Ok, so if you install this extension:

https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools2022

View > Other Windows > Build Logging can record a .binlog you can share here. Maybe send me one that worked and then the failing one, and I can see what's different???

rsfitzii commented 2 years ago

Awesome. Thank you for looking into it.

Attached are the two binlogs. The one marked "Fail" came from the build within VS 2022 using the Build Logger tool you sent me.

The one marked "Success" is the binlog created from the command line MSBuild that was successful.

Both were compiles of the exact same project.

Binlogs.zip

jonathanpeppers commented 2 years ago

Let's track this here, thanks!

https://github.com/xamarin/xamarin-android/issues/6950

rsfitzii commented 2 years ago

Great, thanks!