[xabt] fall back to libZipSharp on .NET framework#10238
Conversation
Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2510554 In testing .NET 10, we found the issue: ADB0010: Mono.AndroidTools.InstallFailedException: Unexpected install output: Failure [-124: Failed parse during installPackageLI: Targeting R+ (version 30 and above) requires the resources.arsc of installed APKs to be stored uncompressed and aligned on a 4-byte boundary] ... 1. Create a new .NET MAUI/MAUI Blazor app. 2. Change the value for the Color attribute to #FF0000 or any color. ```xml <!-- Splash Screen --> <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#FF0000" BaseSize="128,128" /> ``` 3. Deploy to android. 4. The splash screen color should change according to the chosen color. 5. Stop Debugging and change the splash screen color again. 6. If you do it enough times, you would encounter the error. Manually, adding `$(_AndroidUseLibZipSharp)` to the `.csproj` file solves the issue: <_AndroidUseLibZipSharp>true</_AndroidUseLibZipSharp> Reviewing, a `.binlog` created by setting `%MSBUILDDEBUGENGINE%=1` and launching Visual Studio, we see the message: Task BuildArchive ... Using System.IO.Compression because no uncompressed file extensions were specified. So, we are relying on .NET Framework's `System.IO.Compression` to handle `.apk` creation in some cases. `libZipSharp` *was created* because of bugs in .NET Framework's & Mono's implementation of `System.IO.Compression` that caused issues with Android packaging. To fix this, we will always use `libZipSharp` for .NET Framework, regardless if files are compressed or not.
|
|
||
| Log.LogDebugMessage ("Using System.IO.Compression because no files need to be stored uncompressed."); | ||
| // .NET 6+ handles uncompressed files correctly, so we don't need to fallback. | ||
| Log.LogDebugMessage ("Using System.IO.Compression because we're running on .NET 6+."); |
There was a problem hiding this comment.
Is there still a problem with Store in S.I.C ? Or was that fixed?
There was a problem hiding this comment.
Store won't work with .NET framework, for sure. (it also apparently has a new incremental build bug!)
Looking at the old code it did this and returned early for dotnet build:
// .NET 6+ handles uncompressed files correctly, so we don't need to fallback.
if (RuntimeInformation.FrameworkDescription == ".NET") {
Log.LogDebugMessage ("Using System.IO.Compression because we're running on .NET 6+.");
return false;
}I'm just trying to simplify this and return false for dotnet build and true for .NET framework MSBuild.exe.
Original commit is: 7454deb
There was a problem hiding this comment.
This is the line I'm concerned about as https://github.com/dotnet/android/pull/10238/files#diff-3f37e0c1a08fa8b4e139bfec5e8b490cd49e013ad631112ab3dacaf416c3bd83L226 which returned false if Store was NOT used. So if store was used we would fallback to libZipSharp.
There was a problem hiding this comment.
so if there was any content which needed to be stored we would use libZipSharp because S.I.C even on .net 6+ didn't do that properly.
There was a problem hiding this comment.
The function is named backwards imo, but it’s ShouldFallbackToLibZipSharp and true uses LibZipSharp and false System.IO.
Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2510554 In testing .NET 10, we found the issue: ADB0010: Mono.AndroidTools.InstallFailedException: Unexpected install output: Failure [-124: Failed parse during installPackageLI: Targeting R+ (version 30 and above) requires the resources.arsc of installed APKs to be stored uncompressed and aligned on a 4-byte boundary] ... 1. Create a new .NET MAUI/MAUI Blazor app. 2. Change the value for the Color attribute to #FF0000 or any color. ```xml <!-- Splash Screen --> <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#FF0000" BaseSize="128,128" /> ``` 3. Deploy to android. 4. The splash screen color should change according to the chosen color. 5. Stop Debugging and change the splash screen color again. 6. If you do it enough times, you would encounter the error. Manually, adding `$(_AndroidUseLibZipSharp)` to the `.csproj` file solves the issue: <_AndroidUseLibZipSharp>true</_AndroidUseLibZipSharp> Reviewing, a `.binlog` created by setting `%MSBUILDDEBUGENGINE%=1` and launching Visual Studio, we see the message: Task BuildArchive ... Using System.IO.Compression because no uncompressed file extensions were specified. So, we are relying on .NET Framework's `System.IO.Compression` to handle `.apk` creation in some cases. `libZipSharp` *was created* because of bugs in .NET Framework's & Mono's implementation of `System.IO.Compression` that caused issues with Android packaging. To fix this, we will always use `libZipSharp` for .NET Framework, regardless if files are compressed or not.
Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2510554
In testing .NET 10, we found the issue:
Manually, adding
$(_AndroidUseLibZipSharp)to the.csprojfile solves the issue:Reviewing, a
.binlogcreated by setting%MSBUILDDEBUGENGINE%=1and launching Visual Studio, we see the message:So, we are relying on .NET Framework's
System.IO.Compressionto handle.apkcreation in some cases.libZipSharpwas created because of bugs in .NET Framework's & Mono's implementation ofSystem.IO.Compressionthat caused issues with Android packaging.To fix this, we will always use
libZipSharpfor .NET Framework, regardless if files are compressed or not.